feat: export blob type error (#1170)
This commit is contained in:
parent
eee4cabd64
commit
dd91aee89d
@ -3,6 +3,17 @@ import { Result } from 'ahooks/lib/useRequest/src/types';
|
|||||||
import { notification } from 'antd';
|
import { notification } from 'antd';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
|
||||||
|
const handleErrorMessage = (error) => {
|
||||||
|
const reader = new FileReader();
|
||||||
|
reader.readAsText(error?.response?.data, 'utf-8');
|
||||||
|
reader.onload = function () {
|
||||||
|
notification.error({
|
||||||
|
message: JSON.parse(reader.result as string).errors?.map?.((error: any) => {
|
||||||
|
return React.createElement('div', { children: error.message });
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
};
|
||||||
|
};
|
||||||
export class APIClient extends APIClientSDK {
|
export class APIClient extends APIClientSDK {
|
||||||
services: Record<string, Result<any, any>> = {};
|
services: Record<string, Result<any, any>> = {};
|
||||||
|
|
||||||
@ -23,11 +34,15 @@ export class APIClient extends APIClientSDK {
|
|||||||
if (redirectTo) {
|
if (redirectTo) {
|
||||||
return (window.location.href = redirectTo);
|
return (window.location.href = redirectTo);
|
||||||
}
|
}
|
||||||
notification.error({
|
if (error.response.data.type === 'application/json') {
|
||||||
message: error?.response?.data?.errors?.map?.((error: any) => {
|
handleErrorMessage(error);
|
||||||
return React.createElement('div', { children: error.message });
|
} else {
|
||||||
}),
|
notification.error({
|
||||||
});
|
message: error?.response?.data?.errors?.map?.((error: any) => {
|
||||||
|
return React.createElement('div', { children: error.message });
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
}
|
||||||
throw error;
|
throw error;
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user