Advertisement
Guest User

Untitled

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