Micro-service helper: node error
This project is intended to be used in typescript project.
npm i @beecode/msh-error
import { errorFactory } from '@beecode/msh-error'
export const testService = {
someFunction: () => {
// ...
if(isThereAnError) {
throw errorFactory().client.forbidden();
// FORBIDDEN: 403 - FORBIDDEN
// at Object.closure ...
// at file:...
// at ModuleJob.run (node:...) {
// httpCode: 403,
// payload: undefined
// }
}
// ...
}
}
import { errorFactory } from '@beecode/msh-error/dist/error/factory';
export const testService = {
someFunction: () => {
// ...
if(isThereAnError) {
throw errorFactory().client.forbidden('Some custom message');
// FORBIDDEN: Some custom message
// at Object.closure ...
// at file:...
// at ModuleJob.run (node:...) {
// httpCode: 403,
// payload: undefined
// }
}
// ...
}
}
import { errorFactory } from '@beecode/msh-error/dist/error/factory';
export const testService = {
someFunction: () => {
// ...
if(isThereAnError) {
throw errorFactory().client.forbidden({ message:"Some custom message", payload: { some:"custom", data:"here" } });
// FORBIDDEN: Some custom message
// at Object.closure ...
// at file:...
// at ModuleJob.run (node:...) {
// httpCode: 403,
// payload: { some: 'custom', data: 'here' }
// }
}
// ...
}
}