u
This commit is contained in:
20
src/utils/notify.js
Normal file
20
src/utils/notify.js
Normal file
@@ -0,0 +1,20 @@
|
||||
import { enqueueSnackbar } from 'notistack';
|
||||
import { backendErrorFrom } from './backendError';
|
||||
|
||||
/** Show error toast and log to console for debugging. */
|
||||
export function notifyError(err) {
|
||||
const normalized = backendErrorFrom(err);
|
||||
console.error('[error]', normalized.message, {
|
||||
status: normalized.status,
|
||||
path: normalized.path,
|
||||
method: normalized.method,
|
||||
err,
|
||||
});
|
||||
enqueueSnackbar(normalized.message, { variant: 'error' });
|
||||
return normalized;
|
||||
}
|
||||
|
||||
export function notifyErrorMessage(message) {
|
||||
console.error('[error]', message);
|
||||
enqueueSnackbar(message, { variant: 'error' });
|
||||
}
|
||||
Reference in New Issue
Block a user