(code: TCode, ...rest: MaybeOptionalOptions<ORPCErrorOptions<TData>>)
| 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 { |
nothing calls this directly
no test coverage detected