MCPcopy Create free account
hub / github.com/effect-app/libs / defaultFailureMessageHandler

Function defaultFailureMessageHandler

packages/vue/src/commander.ts:2020–2054  ·  view source on GitHub ↗
(
  actionMaker:
    | string
    | ((o: Option.Option<E>, ...args: Args) => string)
    | ((o: Option.Option<E>, ...args: Args) => Effect.Effect<string, AME, AMR>),
  errorRenderer?: ErrorRenderer<E, Args>
)

Source from the content-addressed store, hash-verified

2018})
2019
2020const defaultFailureMessageHandler = <E, Args extends Array<unknown>, AME, AMR>(
2021 actionMaker:
2022 | string
2023 | ((o: Option.Option<E>, ...args: Args) => string)
2024 | ((o: Option.Option<E>, ...args: Args) => Effect.Effect<string, AME, AMR>),
2025 errorRenderer?: ErrorRenderer<E, Args>
2026) =>
2027 Effect.fnUntraced(function*(o: Option.Option<E>, ...args: Args) {
2028 const action = yield* wrapEffect(actionMaker)(o, ...args)
2029 const { intl } = yield* I18n
2030 const renderError = yield* renderErrorMaker
2031
2032 return Option.match(o, {
2033 onNone: () =>
2034 intl.formatMessage(
2035 { id: "handle.unexpected_error2" },
2036 {
2037 action,
2038 error: "" // TODO consider again Cause.pretty(cause), // will be reported to Sentry/Otel anyway.. and we shouldn't bother users with error dumps?
2039 }
2040 ),
2041 onSome: (e) => {
2042 const rendered = renderError(action, errorRenderer)(e, ...args)
2043 return {
2044 level: "warn" as const,
2045 message: `${
2046 intl.formatMessage(
2047 { id: "handle.with_errors" },
2048 { action }
2049 )
2050 }:\n` + rendered
2051 }
2052 }
2053 })
2054 })
2055
2056export const CommanderStatic = {
2057 accessArgs: <In, Out, Arg2, Arg = void>(

Callers 1

commander.tsFile · 0.85

Calls 1

renderErrorFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…