MCPcopy Create free account
hub / github.com/Snowflyt/tinyeffect / catchAllAndThrow

Method catchAllAndThrow

src/effected.ts:1123–1133  ·  view source on GitHub ↗

* Catch all error effects and throw them as an error. * @param message The message of the error. If it is a function, it will be called with the name * and the message of the error effect, and the return value will be used as the message of the * error. * @returns * * @since 0.1.1

(
    message?: string | ((error: string, message?: string) => string | undefined),
  )

Source from the content-addressed store, hash-verified

1121 * @since 0.1.1
1122 */
1123 catchAllAndThrow(
1124 message?: string | ((error: string, message?: string) => string | undefined),
1125 ): Effected<ExcludeEffect<E, Effect.Error>, R> {
1126 return this.catchAll((error, ...args) => {
1127 throw new (buildErrorClass(error))(
1128 ...(typeof message === "string" ? [message]
1129 : typeof message === "function" ? [message(error, ...args)].filter((v) => v !== undefined)
1130 : args),
1131 );
1132 });
1133 }
1134
1135 /**
1136 * Provide a value for a dependency effect.

Callers

nothing calls this directly

Calls 2

catchAllMethod · 0.95
buildErrorClassFunction · 0.85

Tested by

no test coverage detected