mirror of
https://github.com/directus/directus.git
synced 2026-01-30 03:57:58 -05:00
Add toArray util
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user