diff options
author | eug-vs <eug-vs@keemail.me> | 2020-06-25 21:25:18 +0300 |
---|---|---|
committer | eug-vs <eug-vs@keemail.me> | 2020-06-25 21:25:18 +0300 |
commit | fd484a217c77dba42c29fae1cfdb2390422da847 (patch) | |
tree | b11c527bbc0a268f0361a4d56f6aff7011960f98 /hooks/handleErrors.ts | |
parent | 050d3e087b3ce2c9dd892a96daf215402292aa2c (diff) | |
download | which-api-fd484a217c77dba42c29fae1cfdb2390422da847.tar.gz |
feat: add logger and handle eveyrthing nicely
Diffstat (limited to 'hooks/handleErrors.ts')
-rw-r--r-- | hooks/handleErrors.ts | 11 |
1 files changed, 11 insertions, 0 deletions
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<HookContext> => { + context.result = context.error.message; + context.statusCode = context.error.code; + logger.error(context.error); + return context; +}; + |