class ApplicationError extends Data.TaggedError(`ApplicationError`)<{ cause?: unknown }> {}
const someOtherFunction = async () => {
return Promise.reject(new Error('This is an error'))
}
export const handler = () => Effect.gen(function* ($) {
const eff = Effect.tryPromise(() => someOtherFunction())
.pipe(
Effect.mapError(({ error }) => new ApplicationError({ cause: error }))
)
yield* $(eff)
}).pipe(runPromise)
class ApplicationError extends Data.TaggedError(`ApplicationError`)<{ cause?: unknown }> {}
const someOtherFunction = async () => {
return Promise.reject(new Error('This is an error'))
}
export const handler = () => Effect.gen(function* ($) {
const eff = Effect.tryPromise(() => someOtherFunction())
.pipe(
Effect.mapError(({ error }) => new ApplicationError({ cause: error }))
)
yield* $(eff)
}).pipe(runPromise)