class Error1 {
_tag = 'Error1'
}
class Error2 {
_tag = 'Error2'
}
class Error3 {
_tag = 'Error3'
}
// this was my hope to capture any Error channel with at least Error2
const DieOnError2 = <A, E extends Error2, R>(
effect: Ef.Effect<A, E, R>
) => {
return effect.pipe(
Effect.catchTag("Error2", (defect) => Effect.die(defect))
);
};
// pipeline1 is Effect<number, Error1 | Error2, never>
const pipeline1 =
// Type 'Error1 | Error2' is not assignable to type 'Error2'
someComputation.pipe(DieOnError2)
// pipeline2 is Effect<number, Error3 | Error2, never>
const pipeline2 =
// Type 'Error3 | Error2' is not assignable to type 'Error2'
anotherComputation.pipe(DieOnError2)
class Error1 {
_tag = 'Error1'
}
class Error2 {
_tag = 'Error2'
}
class Error3 {
_tag = 'Error3'
}
// this was my hope to capture any Error channel with at least Error2
const DieOnError2 = <A, E extends Error2, R>(
effect: Ef.Effect<A, E, R>
) => {
return effect.pipe(
Effect.catchTag("Error2", (defect) => Effect.die(defect))
);
};
// pipeline1 is Effect<number, Error1 | Error2, never>
const pipeline1 =
// Type 'Error1 | Error2' is not assignable to type 'Error2'
someComputation.pipe(DieOnError2)
// pipeline2 is Effect<number, Error3 | Error2, never>
const pipeline2 =
// Type 'Error3 | Error2' is not assignable to type 'Error2'
anotherComputation.pipe(DieOnError2)