Suggests using Effect.mapError instead of Effect.catch + Effect.fail
| Property | Value |
|---|---|
| Category | Style |
| Default severity | suggestion |
| Fixable | Yes |
| Effect versions | v3, v4 |
| Diagnostic codes | TS377010 |
| Language Service name | catchAllToMapError |
| Oxlint name | effecttsgo/catch-all-to-map-error |
import { Effect } from "effect"
class WrappedError {
constructor(readonly cause: unknown) {}
}
export const preview = Effect.fail("boom").pipe(
Effect.catch((cause) => Effect.fail(new WrappedError(cause)))
/**
^^^^^^^^^^^^ effecttsgo(catch-all-to-map-error): `Effect.mapError` expresses the same error-type transformation more directly than `Effect.catch` followed by `Effect.fail`.
*/
)See the Language Service setup guide for installation instructions.
See the Oxlint setup guide for installation and patching instructions.
{
"$schema": "./node_modules/@effect/tsgo/oxlint-schema.json",
"options": {
"typeAware": true
},
"plugins": ["effecttsgo"],
"rules": {
"effecttsgo/catch-all-to-map-error": "warn"
}
}
{ "$schema": "./node_modules/@effect/tsgo/schema.json", "compilerOptions": { "plugins": [ { "name": "@effect/language-service", "diagnosticSeverity": { "catchAllToMapError": "warning" } } ] } }