Add toArray util

This commit is contained in:
rijkvanzanten
2020-10-15 18:00:27 -04:00
parent cac329c783
commit 592ab925db
13 changed files with 44 additions and 29 deletions

View File

@@ -2,13 +2,14 @@ import { ErrorRequestHandler } from 'express';
import { BaseException } from '../exceptions';
import logger from '../logger';
import env from '../env';
import { toArray } from '../utils/to-array';
const errorHandler: ErrorRequestHandler = (err, req, res, next) => {
let payload: any = {
errors: [],
};
const errors = Array.isArray(err) ? err : [err];
const errors = toArray(err);
if (errors.some((err) => err instanceof BaseException === false)) {
res.status(500);