libshv-js 3.12.0 → 3.12.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/ws-client.ts +19 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "libshv-js",
3
- "version": "3.12.0",
3
+ "version": "3.12.1",
4
4
  "description": "Typescript implementation of libshv",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1",
package/src/ws-client.ts CHANGED
@@ -106,7 +106,25 @@ type DirResult = Array<IMap<{
106
106
 
107
107
  class RpcError extends Error {
108
108
  constructor(readonly err_info: ErrorMap) {
109
- super(err_info[ERROR_MESSAGE] ?? 'Unknown RpcError');
109
+ const errorCodeToMessage = (code: ErrorMap[typeof ERROR_CODE]) => {
110
+ switch (code) {
111
+ case ErrorCode.InvalidRequest: return 'InvalidRequest';
112
+ case ErrorCode.MethodNotFound: return 'MethodNotFound';
113
+ case ErrorCode.InvalidParams: return 'InvalidParams';
114
+ case ErrorCode.InternalError: return 'InternalError';
115
+ case ErrorCode.ParseError: return 'ParseError';
116
+ case ErrorCode.MethodCallTimeout: return 'MethodCallTimeout';
117
+ case ErrorCode.MethodCallCancelled: return 'MethodCallCancelled';
118
+ case ErrorCode.MethodCallException: return 'MethodCallException';
119
+ case ErrorCode.Unknown: return 'Unknown';
120
+ case ErrorCode.LoginRequired: return 'LoginRequired';
121
+ case ErrorCode.UserIDRequired: return 'UserIDRequired';
122
+ case ErrorCode.NotImplemented: return 'NotImplemented';
123
+ default: return 'Unknown RpcError';
124
+ }
125
+ };
126
+
127
+ super(err_info[ERROR_MESSAGE] ?? `${errorCodeToMessage(err_info[ERROR_CODE])} (${err_info[ERROR_CODE]})`);
110
128
  }
111
129
 
112
130
  data() {