// dtos.ts
export interface UserNotFoundDto {
status: 'user-not-found';
message: string;
}
// errors.ts
export const UserNotFoundErrorTag = 'UserNotFoundError' as const;
export class UserNotFoundError extends Error {
readonly _tag = UserNotFoundErrorTag;
constructor(message?: string) {
super(message);
}
}
// adapters.ts
export const userNotFoundDtoFactory = (
error: UserNotFoundError,
): Effect.Effect<UserNotFoundDto> =>
Effect.succeed({ status: 'user-not-found', message: error.message });
export const userNotFoundAdapter = <
A,
E,
R,
F extends Effect.Effect<A, E | UserNotFoundError, R>,
>(
effect: F,
) => effect.pipe(Effect.catchTag(UserNotFoundErrorTag, userNotFoundDtoFactory));
// dtos.ts
export interface UserNotFoundDto {
status: 'user-not-found';
message: string;
}
// errors.ts
export const UserNotFoundErrorTag = 'UserNotFoundError' as const;
export class UserNotFoundError extends Error {
readonly _tag = UserNotFoundErrorTag;
constructor(message?: string) {
super(message);
}
}
// adapters.ts
export const userNotFoundDtoFactory = (
error: UserNotFoundError,
): Effect.Effect<UserNotFoundDto> =>
Effect.succeed({ status: 'user-not-found', message: error.message });
export const userNotFoundAdapter = <
A,
E,
R,
F extends Effect.Effect<A, E | UserNotFoundError, R>,
>(
effect: F,
) => effect.pipe(Effect.catchTag(UserNotFoundErrorTag, userNotFoundDtoFactory));