Skip to content

Commit

Permalink
feat(errorHandler): update handle fnc argument type to MyError | Http…
Browse files Browse the repository at this point in the history
…Error
  • Loading branch information
phatpham9 committed Aug 26, 2020
1 parent 17ee053 commit 769286a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/errorHandler.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { MyError } from './error';
import { MyError, HttpError } from './error';
import logger from './logger';

/**
* Log error to destination then exit the process if programmer error
* @param err error to be handled
*/
const handle = (err: MyError): void => {
const handle = (err: MyError | HttpError): void => {
// E.g. log to sentry
// E.g. log to console
logger.error(err);
Expand Down
2 changes: 1 addition & 1 deletion src/express.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const handleErrors = (
errorHandler.handle(err);

try {
// check if status code exists
// check if status code exists, error thrown if doesn't
getStatusText((err as HttpError).code);

res.status((err as HttpError).code).send(err);
Expand Down

0 comments on commit 769286a

Please sign in to comment.