Spaces:
Build error
Build error
File size: 864 Bytes
d9494a5 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | import { assertUnreachable } from 'twenty-shared/utils';
import {
InternalServerError,
NotFoundError,
} from 'src/engine/core-modules/graphql/utils/graphql-errors.util';
import {
DashboardException,
DashboardExceptionCode,
} from 'src/modules/dashboard/exceptions/dashboard.exception';
export const dashboardGraphqlApiExceptionHandler = (error: Error) => {
if (error instanceof DashboardException) {
switch (error.code) {
case DashboardExceptionCode.DASHBOARD_NOT_FOUND:
throw new NotFoundError(error.message);
case DashboardExceptionCode.PAGE_LAYOUT_NOT_FOUND:
throw new NotFoundError(error.message);
case DashboardExceptionCode.DASHBOARD_DUPLICATION_FAILED:
throw new InternalServerError(error.message);
default: {
return assertUnreachable(error.code);
}
}
}
throw error;
};
|