21 lines
607 B
JavaScript
21 lines
607 B
JavaScript
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' });
|
|
}
|