Use assertReturn to cleanup (#2804)

* Use assertReturn to cleanup

* Remove Uint/Int duplication

* Adjust

* ws errors, part 2

* .

* Adj. manual

* adj

* switchMap

* Revert "switchMap"

This reverts commit edfa4a2258f09042b61a27fd3812f0c53039fe4f.

* Revert.

* Revert.

* protected constructor

* Correct isHexJson flag

* Remove isHexJson (always detect)

* Adjust

* Flags
This commit is contained in:
Jaco Greeff
2020-10-29 17:17:22 +01:00
committed by GitHub
parent 9bb1343255
commit 1f6c8c2eb8
25 changed files with 322 additions and 350 deletions
+13 -11
View File
@@ -22,20 +22,22 @@ const known: Record<number, string> = {
1015: 'TLS Handshake'
};
function getUnmapped (code: number): string | void {
if (code <= 1999) {
return '(For WebSocket standard)';
} else if (code <= 2999) {
return '(For WebSocket extensions)';
} else if (code <= 3999) {
return '(For libraries and frameworks)';
} else if (code <= 4999) {
return '(For applications)';
}
}
export function getWSErrorString (code: number): string {
if (code >= 0 && code <= 999) {
return '(Unused)';
} else if (code >= 1016) {
if (code <= 1999) {
return '(For WebSocket standard)';
} else if (code <= 2999) {
return '(For WebSocket extensions)';
} else if (code <= 3999) {
return '(For libraries and frameworks)';
} else if (code <= 4999) {
return '(For applications)';
}
}
return known[code] || '(Unknown)';
return known[code] || getUnmapped(code) || '(Unknown)';
}