refactor(error): refactor MetaParseError 2
This commit is contained in:
parent
fa1811a330
commit
1c998ab99f
@ -1,5 +1,11 @@
|
||||
import { Jsonable } from '.'
|
||||
|
||||
// Reuse common error messages for meta parsing
|
||||
export enum MetaParseErrorType {
|
||||
'PARSE_ERROR_EVENT' = 'error occurred in parsing the create signature event',
|
||||
'PARSE_ERROR_SIGNATURE_EVENT_CONTENT' = "err in parsing the createSignature event's content"
|
||||
}
|
||||
|
||||
export class MetaParseError extends Error {
|
||||
public readonly context?: Jsonable
|
||||
|
||||
|
@ -4,7 +4,10 @@ import { Event, verifyEvent } from 'nostr-tools'
|
||||
import { toast } from 'react-toastify'
|
||||
import { extractFileExtensions } from './file'
|
||||
import { handleError } from '../types/errors'
|
||||
import { MetaParseError } from '../types/errors/MetaParseError'
|
||||
import {
|
||||
MetaParseError,
|
||||
MetaParseErrorType
|
||||
} from '../types/errors/MetaParseError'
|
||||
|
||||
export enum SignStatus {
|
||||
Signed = 'Signed',
|
||||
@ -19,12 +22,6 @@ export enum SigitStatus {
|
||||
Complete = 'Completed'
|
||||
}
|
||||
|
||||
// Reuse common error messages for meta parsing
|
||||
export enum SigitMetaParseErrorType {
|
||||
'PARSE_ERROR_EVENT' = 'error occurred in parsing the create signature event',
|
||||
'PARSE_ERROR_SIGNATURE_EVENT_CONTENT' = "err in parsing the createSignature event's content"
|
||||
}
|
||||
|
||||
export interface SigitCardDisplayInfo {
|
||||
createdAt?: number
|
||||
title?: string
|
||||
@ -45,7 +42,7 @@ export const parseNostrEvent = async (raw: string): Promise<Event> => {
|
||||
const event = await parseJson<Event>(raw)
|
||||
return event
|
||||
} catch (error) {
|
||||
throw new MetaParseError(SigitMetaParseErrorType.PARSE_ERROR_EVENT, {
|
||||
throw new MetaParseError(MetaParseErrorType.PARSE_ERROR_EVENT, {
|
||||
cause: handleError(error),
|
||||
context: raw
|
||||
})
|
||||
@ -66,7 +63,7 @@ export const parseCreateSignatureEventContent = async (
|
||||
return createSignatureEventContent
|
||||
} catch (error) {
|
||||
throw new MetaParseError(
|
||||
SigitMetaParseErrorType.PARSE_ERROR_SIGNATURE_EVENT_CONTENT,
|
||||
MetaParseErrorType.PARSE_ERROR_SIGNATURE_EVENT_CONTENT,
|
||||
{
|
||||
cause: handleError(error),
|
||||
context: raw
|
||||
|
Loading…
Reference in New Issue
Block a user