mirror of
https://github.com/stefanpejcic/openpanel
synced 2025-06-26 18:28:26 +00:00
fork refine
This commit is contained in:
18
packages/strapi-v4/src/utils/transformHttpError.ts
Normal file
18
packages/strapi-v4/src/utils/transformHttpError.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import { HttpError } from "@refinedev/core";
|
||||
import { transformErrorMessages } from "./transformErrorMessages";
|
||||
|
||||
export const transformHttpError = (err: any): HttpError => {
|
||||
const error = err?.response?.data?.error || {};
|
||||
|
||||
const message = error?.message;
|
||||
const statusCode = error?.status;
|
||||
const errorMessages = error?.details?.errors || [];
|
||||
|
||||
const httpError: HttpError = {
|
||||
statusCode,
|
||||
message,
|
||||
errors: transformErrorMessages(errorMessages),
|
||||
};
|
||||
|
||||
return httpError;
|
||||
};
|
||||
Reference in New Issue
Block a user