type Item = { id: string }
const someOption = Option.some('foo')
const foo = (items: Item[]) =>
Effect.gen(function* () {
// Could fail with NoSuchElementException
const item = yield* Array.findFirst(items, (i) => i.id === 'foo')
// Could also fail with NoSuchElementException
const item2 = yield* someOption
return item.id.concat(item2)
})
const result = foo([{ id: '1' }, { id: '2' }]).pipe(
// Error is NoSuchElementException, but no indication which
// I want this error to be detailed with a stack trace to which
// NoSuchElementException was raised
Effect.catchAll((error) =>
Effect.sync(() => {
// Send error to error monitoring service
})
)
)
type Item = { id: string }
const someOption = Option.some('foo')
const foo = (items: Item[]) =>
Effect.gen(function* () {
// Could fail with NoSuchElementException
const item = yield* Array.findFirst(items, (i) => i.id === 'foo')
// Could also fail with NoSuchElementException
const item2 = yield* someOption
return item.id.concat(item2)
})
const result = foo([{ id: '1' }, { id: '2' }]).pipe(
// Error is NoSuchElementException, but no indication which
// I want this error to be detailed with a stack trace to which
// NoSuchElementException was raised
Effect.catchAll((error) =>
Effect.sync(() => {
// Send error to error monitoring service
})
)
)