localized-error
v1.4.0
Published
Java-style chained custom errors for Typescript and Javascript. ('Caused by' in error stack)
Downloads
8
Readme
Localized error
Highlights
- Server-side error localization
- Typescript typings
- Errors generated by factory, allow extending custom errors
Installation
$ npm install --save localized-error
Usage
Example usage with firebase HttpsError:
import * as functions from "firebase-functions";
import { LocalizedError, LocalizedErrorFactory } from "localized-error";
export interface SystemError extends LocalizedError {
details: {
advanced: string;
localizedMessage: {},
};
}
export namespace SystemError {
const localizedMessage = {
EN: "Unexpected system error occured. Please contact the system administrator",
PL: "Wystąpił błąd systemu. Proszę skontaktować się z administratorem",
};
export function make(error: Error): SystemError {
const advanced = error.message;
const unknownFirebaseError = new functions.https.HttpsError("unknown", localizedMessage.EN, { advanced });
return LocalizedErrorFactory.make(unknownFirebaseError, localizedMessage) as SystemError;
}
}
Informations
Need help?
- Feel free to email me at [email protected]
Would like to help?
Warmly welcomed:
- Bug reports via issues
- Enhancement requests via via issues
- Pull requests
- Security reports to [email protected]
Made with ❤️ by Jędrzej Lewandowski