error-message-utils 1.2.2 → 1.2.4
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.
- package/README.md +14 -0
- package/dist/exception/index.d.ts +1 -1
- package/dist/exception/index.js +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -172,6 +172,20 @@ type IDecodedError = {
|
|
|
172
172
|
```
|
|
173
173
|
|
|
174
174
|
|
|
175
|
+
<br/>
|
|
176
|
+
|
|
177
|
+
## Constants
|
|
178
|
+
|
|
179
|
+
```typescript
|
|
180
|
+
// the default message if none can be extracted
|
|
181
|
+
const DEFAULT_MESSAGE: string =
|
|
182
|
+
'The error message could not be extracted, check the logs for more information.';
|
|
183
|
+
|
|
184
|
+
// the default code if none was provided or could not be extracted
|
|
185
|
+
const DEFAULT_CODE: IErrorCode = -1;
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
|
|
175
189
|
|
|
176
190
|
<br/>
|
|
177
191
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type IErrorCode } from '../shared/types.js';
|
|
2
2
|
export declare class Exception extends Error {
|
|
3
3
|
readonly code: IErrorCode;
|
|
4
|
-
constructor(error: unknown, code
|
|
4
|
+
constructor(error: unknown, code?: IErrorCode);
|
|
5
5
|
/**
|
|
6
6
|
* Override the default toString method to return a formatted error message with the code.
|
|
7
7
|
* @returns A string representation of the error with the code.
|
package/dist/exception/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{encodeError
|
|
1
|
+
import{decodeError,encodeError}from"../error-handler/index.js";export class Exception extends Error{code;constructor(r,e){const o=decodeError(r);super(o.message),this.name="Exception",this.code=e??o.code}toString(){return encodeError(this.message,this.code)}[Symbol.toPrimitive](r){return"string"===r||"default"===r?this.toString():null}}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { IErrorCode, IDecodedError } from './shared/types.js';
|
|
2
|
+
import { DEFAULT_CODE, DEFAULT_MESSAGE } from './shared/constants.js';
|
|
2
3
|
import { decodeError, encodeError, extractMessage, isDefaultErrorMessage, isEncodedError } from './error-handler/index.js';
|
|
3
4
|
import { Exception } from './exception/index.js';
|
|
4
5
|
/**
|
|
5
6
|
* Module exports
|
|
6
7
|
*/
|
|
7
|
-
export { type IErrorCode, type IDecodedError, extractMessage, encodeError, decodeError, isEncodedError, isDefaultErrorMessage, Exception, };
|
|
8
|
+
export { type IErrorCode, type IDecodedError, DEFAULT_MESSAGE, DEFAULT_CODE, extractMessage, encodeError, decodeError, isEncodedError, isDefaultErrorMessage, Exception, };
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{decodeError,encodeError,extractMessage,isDefaultErrorMessage,isEncodedError}from"./error-handler/index.js";import{Exception}from"./exception/index.js";export{extractMessage,encodeError,decodeError,isEncodedError,isDefaultErrorMessage,Exception};
|
|
1
|
+
import{DEFAULT_CODE,DEFAULT_MESSAGE}from"./shared/constants.js";import{decodeError,encodeError,extractMessage,isDefaultErrorMessage,isEncodedError}from"./error-handler/index.js";import{Exception}from"./exception/index.js";export{DEFAULT_MESSAGE,DEFAULT_CODE,extractMessage,encodeError,decodeError,isEncodedError,isDefaultErrorMessage,Exception};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "error-message-utils",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.4",
|
|
4
4
|
"description": "The error-message-utils package simplifies error management in your web applications and RESTful APIs. It ensures consistent and scalable handling of error messages, saving you time and effort. Moreover, it gives you the ability to assign custom error codes so all possible cases can be handled accordingly.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|