* Catch an error effect and throw it as an error. * @param name The name of the error effect. * @param message The message of the error. If it is a function, it will be called with the * message of the error effect, and the return value will be used as the message of the error. * @return
(
name: Name,
message?: string | ((message?: string) => string | undefined),
)
| 1099 | * @since 0.1.1 |
| 1100 | */ |
| 1101 | catchAndThrow<Name extends ErrorName<ExtractEffect<E>>>( |
| 1102 | name: Name, |
| 1103 | message?: string | ((message?: string) => string | undefined), |
| 1104 | ): Effected<ExcludeEffect<E, Effect.Error<Name>>, R> { |
| 1105 | return this.catch(name, (...args) => { |
| 1106 | throw new (buildErrorClass(name))( |
| 1107 | ...(typeof message === "string" ? [message] |
| 1108 | : typeof message === "function" ? [message(...args)].filter((v) => v !== undefined) |
| 1109 | : args), |
| 1110 | ); |
| 1111 | }); |
| 1112 | } |
| 1113 | |
| 1114 | /** |
| 1115 | * Catch all error effects and throw them as an error. |
nothing calls this directly
no test coverage detected