From fd484a217c77dba42c29fae1cfdb2390422da847 Mon Sep 17 00:00:00 2001 From: eug-vs Date: Thu, 25 Jun 2020 21:25:18 +0300 Subject: feat: add logger and handle eveyrthing nicely --- hooks/handleErrors.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 hooks/handleErrors.ts (limited to 'hooks/handleErrors.ts') diff --git a/hooks/handleErrors.ts b/hooks/handleErrors.ts new file mode 100644 index 0000000..2a3c728 --- /dev/null +++ b/hooks/handleErrors.ts @@ -0,0 +1,11 @@ +import { HookContext } from '@feathersjs/feathers'; +import logger from '../logger'; + + +export default async (context: HookContext): Promise => { + context.result = context.error.message; + context.statusCode = context.error.code; + logger.error(context.error); + return context; +}; + -- cgit v1.2.3