Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- commit ********b2a5c668b54348d0f3f891ddc58ef9f8
- Author: Christoph Tavan <christoph@contentpass.de>
- Date: Mon Mar 11 16:53:10 2019 +0100
- Fix sorting of error codes
- Apparently with node 11 there's a subtle change in how array sorting
- compare function return values are interpreted. According to the spec
- the return value of 0 will not change the sorting. A negative return
- value will sort the element below and must be used in this case.
- It's interesting that a return value of 0 was behaving like a return
- value of -1 in node 10 but behaves differently in node 11.
- diff --git a/services/core/lib/common/error/ErrorCode.js b/services/core/lib/common/error/ErrorCode.js
- index b7576ce1..d2bf712d 100644
- --- a/services/core/lib/common/error/ErrorCode.js
- +++ b/services/core/lib/common/error/ErrorCode.js
- @@ -71,7 +71,7 @@ export default class ErrorCode {
- // Required to make sure they already exist when instantiating
- // error codes that reference them as their publicErrorCode.
- function listPublicErrorsFirst(code) {
- - return codes[code].publicErrorCode ? 1 : 0;
- + return codes[code].publicErrorCode ? 1 : -1;
- }
- Object.keys(codes).sort(listPublicErrorsFirst).forEach((code) => {
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement