@@ -33,7 +33,7 @@ export const COMMON_ERROR_STATUS_MAP = {
3333 BAD_GATEWAY : 502 ,
3434 SERVICE_UNAVAILABLE : 503 ,
3535 GATEWAY_TIMEOUT : 504 ,
36- }
36+ } as const
3737
3838/**
3939 * Error codes accepted by `ORPCError`: common HTTP codes plus any string.
@@ -90,19 +90,19 @@ export class ORPCError<TCode extends ORPCErrorCode, TData> extends Error {
9090
9191 /**
9292 * @remarks
93- * **Note**: The `__branch ` property is used for type branding, helping TypeScript distinguish
93+ * **Note**: The `__brand ` property is used for type branding, helping TypeScript distinguish
9494 * an `ORPCError` instance from plain objects with a similar structure.
9595 */
96- override readonly name = 'ORPCError' as 'ORPCError' & { __branch : 'ORPCError' }
96+ override readonly name = 'ORPCError' as 'ORPCError' & { __brand : 'ORPCError' }
9797
9898 /**
9999 * Indicates whether the error matches a definition in the procedure's `.errors` map,
100100 * which makes its type inferable on the client.
101101 */
102102 readonly defined : boolean = false
103103
104- code : TCode
105- data : TData
104+ readonly code : TCode
105+ readonly data : TData
106106
107107 constructor ( code : TCode , ...rest : MaybeOptionalOptions < ORPCErrorOptions < TData > > ) {
108108 const options = resolveMaybeOptionalOptions ( rest )
@@ -151,14 +151,14 @@ export class ORPCError<TCode extends ORPCErrorCode, TData> extends Error {
151151 }
152152}
153153
154- export interface ORPCErrorJSON < TCode extends string , TData > extends Pick <
155- ORPCError < TCode , TData > ,
156- 'code' | 'message' | 'data'
157- > {
158- /**
159- * remove readonly
160- */
154+ /**
155+ * Plain serialized form of an `ORPCError`. Unlike the class, its fields are writable.
156+ */
157+ export interface ORPCErrorJSON < TCode extends string , TData > {
161158 defined : boolean
159+ code : TCode
160+ message : string
161+ data : TData
162162}
163163
164164export type AnyORPCError = ORPCError < any , any >
0 commit comments