pipe(
someEffect(id),
Effect.match({
onSuccess: (result) = > Effect.succeed(result),
onFailure: (error) =>
Match.value(error._tag).pipe(
Match.when(‘QueryError’, () =>
pipe(
Effect.fail(() => new InternalServerErrorException(error)),
Effect.tap(() =>
this.logger.error(
'[ Controller ]: some error happened ${id}',
{ error }
)
)
)
),
Match.when(‘FooError’, () =>
pipe(
Effect.fail(() => new NotFoundException(error)),
Effect.tap(() =>
this.logger.error(‘some error’, { error })
)
)
),
Match.exhaustive
),
}),
Effect.flatten
);
pipe(
someEffect(id),
Effect.match({
onSuccess: (result) = > Effect.succeed(result),
onFailure: (error) =>
Match.value(error._tag).pipe(
Match.when(‘QueryError’, () =>
pipe(
Effect.fail(() => new InternalServerErrorException(error)),
Effect.tap(() =>
this.logger.error(
'[ Controller ]: some error happened ${id}',
{ error }
)
)
)
),
Match.when(‘FooError’, () =>
pipe(
Effect.fail(() => new NotFoundException(error)),
Effect.tap(() =>
this.logger.error(‘some error’, { error })
)
)
),
Match.exhaustive
),
}),
Effect.flatten
);