Files
TheGame/packages/web/lib/errors.ts
2023-03-14 11:57:07 -06:00

15 lines
464 B
TypeScript

import { errorHandler } from 'utils/errorHandler';
export class CeramicError extends Error {}
export const handleCeramicAuthenticationError = (err: Error) => {
if (err.message === 'Unexpected token u in JSON at position 0') {
throw new CeramicError('User canceled authentication.');
}
if (err.message === '"undefined" is not valid JSON') {
throw new CeramicError('Could not authenticate with Ceramic API');
}
errorHandler(err);
throw err;
};