Improve api error dialog

This commit is contained in:
syuilo 2020-10-18 10:21:02 +09:00
parent 2d26ebb041
commit 18ea1d88db

View file

@ -70,7 +70,12 @@ export function apiWithDialog(
onFailure?: (e: Error) => void,
) {
const promise = api(endpoint, data, token);
promiseDialog(promise, onSuccess, onFailure);
promiseDialog(promise, onSuccess, onFailure ? onFailure : (e) => {
dialog({
type: 'error',
text: e.message + '\n' + (e as any).id,
});
});
return promise;
}