UNPKG

mod-arch-core

Version:

Core functionality and API utilities for modular architecture micro-frontend projects

22 lines 727 B
import { isCommonStateError } from '../utilities/useFetchState'; const isError = (e) => typeof e === 'object' && e !== null && 'error' in e; export const handleRestFailures = (promise) => promise .then((result) => { if (isError(result)) { throw result; } return result; }) .catch((e) => { if (isError(e)) { throw new Error(e.error.message); } if (isCommonStateError(e)) { // Common state errors are handled by useFetchState at storage level, let them deal with it throw e; } // eslint-disable-next-line no-console console.error('Unknown API error', e); throw new Error('Error communicating with server'); }); //# sourceMappingURL=errorUtils.js.map