MCPcopy Create free account
hub / github.com/middleapi/orpc / constructor

Method constructor

packages/client/src/error.ts:139–154  ·  view source on GitHub ↗
(code: TCode, ...rest: MaybeOptionalOptions<ORPCErrorOptions<TData>>)

Source from the content-addressed store, hash-verified

137 }
138
139 constructor(code: TCode, ...rest: MaybeOptionalOptions<ORPCErrorOptions<TData>>) {
140 const options = resolveMaybeOptionalOptions(rest)
141
142 if (options.status !== undefined && !isORPCErrorStatus(options.status)) {
143 throw new Error('[ORPCError] Invalid error status code.')
144 }
145
146 const message = fallbackORPCErrorMessage(code, options.message)
147
148 super(message, options)
149
150 this.code = code
151 this.status = fallbackORPCErrorStatus(code, options.status)
152 this.defined = options.defined ?? false
153 this.data = options.data as TData // data only optional when TData is undefinable so can safely cast here
154 }
155
156 toJSON(): ORPCErrorJSON<TCode, TData> {
157 return {

Callers

nothing calls this directly

Calls 4

isORPCErrorStatusFunction · 0.85
fallbackORPCErrorMessageFunction · 0.85
fallbackORPCErrorStatusFunction · 0.85

Tested by

no test coverage detected