Skip to content

refactor: replace better-result with faultier for error handling#94

Merged
adelrodriguez merged 1 commit intomainfrom
02-18-refactor_replace_better-result_with_faultier_for_error_handling
Feb 19, 2026
Merged

refactor: replace better-result with faultier for error handling#94
adelrodriguez merged 1 commit intomainfrom
02-18-refactor_replace_better-result_with_faultier_for_error_handling

Conversation

@adelrodriguez
Copy link
Collaborator

@adelrodriguez adelrodriguez commented Feb 19, 2026

Greptile Summary

This PR successfully migrates the error handling system from better-result to faultier. The refactor is complete and correctly implements the new API, including updating all error class definitions to use Faultier.Tagged, introducing fault registries for each error domain (AuthFault, EmailFault, UtilityFault), and merging them into a unified AppFault registry.

Key changes:

  • Replaced better-result dependency with faultier@2.2.0 in package.json
  • Updated all error imports from import { TaggedError } from "better-result" to import * as Faultier from "faultier"
  • Migrated error class definitions from TaggedError(...) to Faultier.Tagged(...)
  • Fixed tag name inconsistencies (AuthenticationErrorUnauthenticatedError, AuthorizationErrorUnauthorizedError)
  • Removed constructor-based custom messages in favor of .withMessage() method calls
  • Created fault registries using Faultier.registry() for better error handling organization
  • Added new InvalidBaseUrlError utility error
  • Exported faultier utilities (matchTag, matchTags, Fault) from the main index

The migration correctly adapts to faultier's API differences, particularly the builder pattern for adding messages via .withMessage() rather than constructor arguments.

Confidence Score: 5/5

  • This PR is safe to merge with no blocking issues
  • The refactor is complete and thorough. All imports have been updated correctly, the API migration follows faultier's documented patterns, error registries are properly created and merged, and existing error usage sites have been updated to use the new .withMessage() API. The changes maintain backward compatibility in terms of exported types and error behavior.
  • No files require special attention

Important Files Changed

Filename Overview
packages/error/package.json Updated dependency from better-result to faultier@2.2.0
packages/error/src/utils.ts Migrated to Faultier.Tagged, removed constructor custom messages, added UtilityFault registry and new InvalidBaseUrlError
packages/error/src/auth.ts Migrated to Faultier.Tagged, fixed tag names to match class names, added AuthFault registry
packages/error/src/email.ts Migrated to Faultier.Tagged and added EmailFault registry
packages/error/src/index.ts Merged fault registries into AppFault, exported faultier utilities (matchTag, matchTags, Fault)
packages/utils/src/assert.ts Updated error instantiation to use .withMessage() method instead of passing message in constructor

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[better-result] -->|Replaced with| B[faultier]
    B --> C[Tagged errors]
    C --> D[utils.ts errors]
    C --> E[auth.ts errors]
    C --> F[email.ts errors]
    D --> G[UtilityFault registry]
    E --> H[AuthFault registry]
    F --> I[EmailFault registry]
    G --> J[AppFault]
    H --> J
    I --> J
    J --> K[Exported from index.ts]
    L[assert.ts] -->|Uses| M[.withMessage method]
    M -->|New API| B
Loading

Last reviewed commit: ae5df0e

@coderabbitai
Copy link

coderabbitai bot commented Feb 19, 2026

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch 02-18-refactor_replace_better-result_with_faultier_for_error_handling

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@adelrodriguez adelrodriguez marked this pull request as ready for review February 19, 2026 03:10
Copy link
Collaborator Author

adelrodriguez commented Feb 19, 2026

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 files reviewed, 11 comments

Edit Code Review Agent Settings | Greptile

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Import still references better-result but the dependency was changed to faultier. This will cause a module not found error.

Suggested change
import { Tagged } from "faultier"

Note: faultier exports Tagged instead of TaggedError. You'll need to update all usages accordingly.

Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/error/src/utils.ts
Line: 1

Comment:
Import still references `better-result` but the dependency was changed to `faultier`. This will cause a module not found error.

```suggestion
import { Tagged } from "faultier"
```

Note: `faultier` exports `Tagged` instead of `TaggedError`. You'll need to update all usages accordingly.

How can I resolve this? If you propose a fix, please make it concise.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Import still references better-result but the dependency was changed to faultier.

Suggested change
import { Tagged } from "faultier"
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/error/src/auth.ts
Line: 1

Comment:
Import still references `better-result` but the dependency was changed to `faultier`.

```suggestion
import { Tagged } from "faultier"
```

How can I resolve this? If you propose a fix, please make it concise.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Import still references better-result but the dependency was changed to faultier.

Suggested change
import { Tagged } from "faultier"
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/error/src/email.ts
Line: 1

Comment:
Import still references `better-result` but the dependency was changed to `faultier`.

```suggestion
import { Tagged } from "faultier"
```

How can I resolve this? If you propose a fix, please make it concise.

Comment on lines 3 to 10
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TaggedError needs to be replaced with Tagged to match faultier's API.

Suggested change
export class InvalidDurationParseInputError extends Tagged("InvalidDurationParseInputError")<{
message: string
value: string
}>() {
constructor(props: { value: string }) {
super({ ...props, message: `Unable to parse duration from input: "${props.value}"` })
}
}
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/error/src/utils.ts
Line: 3-10

Comment:
`TaggedError` needs to be replaced with `Tagged` to match `faultier`'s API.

```suggestion
export class InvalidDurationParseInputError extends Tagged("InvalidDurationParseInputError")<{
  message: string
  value: string
}>() {
  constructor(props: { value: string }) {
    super({ ...props, message: `Unable to parse duration from input: "${props.value}"` })
  }
}
```

How can I resolve this? If you propose a fix, please make it concise.

Comment on lines 12 to 18
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TaggedError needs to be replaced with Tagged.

Suggested change
export class InvalidDurationFormatInputError extends Tagged(
"InvalidDurationFormatInputError"
)<{ message: string }>() {
constructor() {
super({ message: "Invalid duration format provided" })
}
}
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/error/src/utils.ts
Line: 12-18

Comment:
`TaggedError` needs to be replaced with `Tagged`.

```suggestion
export class InvalidDurationFormatInputError extends Tagged(
  "InvalidDurationFormatInputError"
)<{ message: string }>() {
  constructor() {
    super({ message: "Invalid duration format provided" })
  }
}
```

How can I resolve this? If you propose a fix, please make it concise.

Comment on lines 24 to 27
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TaggedError needs to be replaced with Tagged.

Suggested change
export class AssertConditionFailedError extends Tagged("AssertConditionFailedError")<{
message: string
condition: string
}>() {}
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/error/src/utils.ts
Line: 24-27

Comment:
`TaggedError` needs to be replaced with `Tagged`.

```suggestion
export class AssertConditionFailedError extends Tagged("AssertConditionFailedError")<{
  message: string
  condition: string
}>() {}
```

How can I resolve this? If you propose a fix, please make it concise.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TaggedError needs to be replaced with Tagged.

Suggested change
export class UnauthenticatedError extends Tagged("AuthenticationError")() {}
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/error/src/auth.ts
Line: 3

Comment:
`TaggedError` needs to be replaced with `Tagged`.

```suggestion
export class UnauthenticatedError extends Tagged("AuthenticationError")() {}
```

How can I resolve this? If you propose a fix, please make it concise.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TaggedError needs to be replaced with Tagged.

Suggested change
export class UnauthorizedError extends Tagged("AuthorizationError")<{ userId: string }>() {}
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/error/src/auth.ts
Line: 5

Comment:
`TaggedError` needs to be replaced with `Tagged`.

```suggestion
export class UnauthorizedError extends Tagged("AuthorizationError")<{ userId: string }>() {}
```

How can I resolve this? If you propose a fix, please make it concise.

Comment on lines 3 to 8
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TaggedError needs to be replaced with Tagged.

Suggested change
export class SendEmailError extends Tagged("SendEmailError")<{
emails: string[]
subject: string
from?: string
text: string
}>() {}
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/error/src/email.ts
Line: 3-8

Comment:
`TaggedError` needs to be replaced with `Tagged`.

```suggestion
export class SendEmailError extends Tagged("SendEmailError")<{
  emails: string[]
  subject: string
  from?: string
  text: string
}>() {}
```

How can I resolve this? If you propose a fix, please make it concise.

Comment on lines 10 to 14
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TaggedError needs to be replaced with Tagged.

Suggested change
export class BatchSendEmailError extends Tagged("BatchSendEmailError")<{
emails: string[]
subject: string
from?: string
}>() {}
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/error/src/email.ts
Line: 10-14

Comment:
`TaggedError` needs to be replaced with `Tagged`.

```suggestion
export class BatchSendEmailError extends Tagged("BatchSendEmailError")<{
  emails: string[]
  subject: string
  from?: string
}>() {}
```

How can I resolve this? If you propose a fix, please make it concise.

@adelrodriguez adelrodriguez force-pushed the 02-18-refactor_move_mobile_breakpoint_from_utils_to_ui_package branch from 058dcb0 to 8973883 Compare February 19, 2026 03:24
@adelrodriguez adelrodriguez force-pushed the 02-18-refactor_replace_better-result_with_faultier_for_error_handling branch from ef7ac57 to 7507d4a Compare February 19, 2026 03:25
Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

@adelrodriguez adelrodriguez force-pushed the 02-18-refactor_move_mobile_breakpoint_from_utils_to_ui_package branch from 8973883 to bf8d6d6 Compare February 19, 2026 03:29
@adelrodriguez adelrodriguez force-pushed the 02-18-refactor_replace_better-result_with_faultier_for_error_handling branch from 7507d4a to b8577bc Compare February 19, 2026 03:29
@adelrodriguez adelrodriguez force-pushed the 02-18-refactor_move_mobile_breakpoint_from_utils_to_ui_package branch 2 times, most recently from eac8e82 to acb844a Compare February 19, 2026 03:33
@adelrodriguez adelrodriguez force-pushed the 02-18-refactor_replace_better-result_with_faultier_for_error_handling branch from b8577bc to 3f35747 Compare February 19, 2026 03:33
Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

@adelrodriguez adelrodriguez force-pushed the 02-18-refactor_replace_better-result_with_faultier_for_error_handling branch from 3f35747 to 194a280 Compare February 19, 2026 03:38
@adelrodriguez adelrodriguez changed the base branch from 02-18-refactor_move_mobile_breakpoint_from_utils_to_ui_package to graphite-base/94 February 19, 2026 03:52
@adelrodriguez adelrodriguez force-pushed the 02-18-refactor_replace_better-result_with_faultier_for_error_handling branch from 194a280 to 82e83d3 Compare February 19, 2026 03:52
@graphite-app graphite-app bot changed the base branch from graphite-base/94 to main February 19, 2026 03:53
@adelrodriguez adelrodriguez force-pushed the 02-18-refactor_replace_better-result_with_faultier_for_error_handling branch 3 times, most recently from 39ff9b8 to ae5df0e Compare February 19, 2026 03:53
@adelrodriguez adelrodriguez merged commit 562f8f7 into main Feb 19, 2026
7 checks passed
@adelrodriguez adelrodriguez deleted the 02-18-refactor_replace_better-result_with_faultier_for_error_handling branch February 19, 2026 03:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Comments