new release #190

Merged
b merged 68 commits from staging into main 2024-09-06 18:59:34 +00:00
2 changed files with 12 additions and 9 deletions
Showing only changes of commit 1c998ab99f - Show all commits

View File

@ -1,5 +1,11 @@
import { Jsonable } from '.' 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 { export class MetaParseError extends Error {
public readonly context?: Jsonable public readonly context?: Jsonable

View File

@ -4,7 +4,10 @@ import { Event, verifyEvent } from 'nostr-tools'
import { toast } from 'react-toastify' import { toast } from 'react-toastify'
import { extractFileExtensions } from './file' import { extractFileExtensions } from './file'
import { handleError } from '../types/errors' import { handleError } from '../types/errors'
import { MetaParseError } from '../types/errors/MetaParseError' import {
MetaParseError,
MetaParseErrorType
} from '../types/errors/MetaParseError'
export enum SignStatus { export enum SignStatus {
Signed = 'Signed', Signed = 'Signed',
@ -19,12 +22,6 @@ export enum SigitStatus {
Complete = 'Completed' 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 { export interface SigitCardDisplayInfo {
createdAt?: number createdAt?: number
title?: string title?: string
@ -45,7 +42,7 @@ export const parseNostrEvent = async (raw: string): Promise<Event> => {
const event = await parseJson<Event>(raw) const event = await parseJson<Event>(raw)
return event return event
} catch (error) { } catch (error) {
throw new MetaParseError(SigitMetaParseErrorType.PARSE_ERROR_EVENT, { throw new MetaParseError(MetaParseErrorType.PARSE_ERROR_EVENT, {
cause: handleError(error), cause: handleError(error),
context: raw context: raw
}) })
@ -66,7 +63,7 @@ export const parseCreateSignatureEventContent = async (
return createSignatureEventContent return createSignatureEventContent
} catch (error) { } catch (error) {
throw new MetaParseError( throw new MetaParseError(
SigitMetaParseErrorType.PARSE_ERROR_SIGNATURE_EVENT_CONTENT, MetaParseErrorType.PARSE_ERROR_SIGNATURE_EVENT_CONTENT,
{ {
cause: handleError(error), cause: handleError(error),
context: raw context: raw