Fixed logic to determine if an error is a ProblemDetailError

This commit is contained in:
Alejandro Celaya 2022-11-15 12:15:04 +01:00
parent 1eab5af5c7
commit f7ba974d97

View file

@ -8,7 +8,7 @@ import {
} from '../types/errors';
const isProblemDetails = (e: unknown): e is ProblemDetailsError =>
!!e && typeof e === 'object' && Object.keys(e).every((key) => ['type', 'detail', 'title', 'status'].includes(key));
!!e && typeof e === 'object' && ['type', 'detail', 'title', 'status'].every((prop) => prop in e);
export const parseApiError = (e: unknown): ProblemDetailsError | undefined => (isProblemDetails(e) ? e : undefined);