* Get an error message and optional data from an options bag. * * @param arg - The error message or options bag. * @returns A tuple containing the error message and optional data.
( arg?: JsonRpcErrorsArg<Data>, )
| 282 | * @returns A tuple containing the error message and optional data. |
| 283 | */ |
| 284 | function parseOpts<Data extends OptionalDataWithOptionalCause>( |
| 285 | arg?: JsonRpcErrorsArg<Data>, |
| 286 | ): [message?: string | undefined, data?: Data | undefined] { |
| 287 | if (arg) { |
| 288 | if (typeof arg === 'string') { |
| 289 | return [arg]; |
| 290 | } else if (typeof arg === 'object' && !Array.isArray(arg)) { |
| 291 | const { message, data } = arg; |
| 292 | |
| 293 | if (message && typeof message !== 'string') { |
| 294 | throw new Error('Must specify string message.'); |
| 295 | } |
| 296 | return [message ?? undefined, data]; |
| 297 | } |
| 298 | } |
| 299 | |
| 300 | return []; |
| 301 | } |
no outgoing calls
no test coverage detected
searching dependent graphs…