Skip to content

Commit dfabc75

Browse files
committed
feat: export mapErrors method
the method can be used to transform object literals to IntlErrors
1 parent 9344039 commit dfabc75

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

src/errors.d.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
declare class IntlError {
2-
_error: {
3-
code: string;
4-
name: string;
5-
message: string;
6-
};
72
name: string;
8-
constructor(error: any);
9-
appendMessage(message: string): void;
3+
message: string;
4+
constructor(error: { name: string, message: string });
105
formatMessage(...values: any[]): string;
6+
error(...values: any[]): Error;
117
}
128
declare const errors: any;
13-
export { errors, IntlError };
9+
declare const mapErrors: (errors: { [x: string]: string; }) => { [x: string]: IntlError };
10+
11+
export { errors, mapErrors, IntlError };

src/errors.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,5 +47,6 @@ const errors = mapErrors(errorDetails);
4747

4848
export {
4949
errors,
50+
mapErrors,
5051
IntlError
5152
};

0 commit comments

Comments
 (0)