refactor: replace better-result with faultier for error handling#94
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
This stack of pull requests is managed by Graphite. Learn more about stacking. |
packages/error/src/utils.ts
Outdated
There was a problem hiding this comment.
Import still references better-result but the dependency was changed to faultier. This will cause a module not found error.
| 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.
packages/error/src/auth.ts
Outdated
There was a problem hiding this comment.
Import still references better-result but the dependency was changed to faultier.
| 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.
packages/error/src/email.ts
Outdated
There was a problem hiding this comment.
Import still references better-result but the dependency was changed to faultier.
| 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.
packages/error/src/utils.ts
Outdated
There was a problem hiding this comment.
TaggedError needs to be replaced with Tagged to match faultier's API.
| 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.
packages/error/src/utils.ts
Outdated
There was a problem hiding this comment.
TaggedError needs to be replaced with Tagged.
| 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.
packages/error/src/utils.ts
Outdated
There was a problem hiding this comment.
TaggedError needs to be replaced with Tagged.
| 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.
packages/error/src/auth.ts
Outdated
There was a problem hiding this comment.
TaggedError needs to be replaced with Tagged.
| 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.
packages/error/src/auth.ts
Outdated
There was a problem hiding this comment.
TaggedError needs to be replaced with Tagged.
| 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.
packages/error/src/email.ts
Outdated
There was a problem hiding this comment.
TaggedError needs to be replaced with Tagged.
| 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.
packages/error/src/email.ts
Outdated
There was a problem hiding this comment.
TaggedError needs to be replaced with Tagged.
| 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.058dcb0 to
8973883
Compare
ef7ac57 to
7507d4a
Compare
8973883 to
bf8d6d6
Compare
7507d4a to
b8577bc
Compare
eac8e82 to
acb844a
Compare
b8577bc to
3f35747
Compare
3f35747 to
194a280
Compare
acb844a to
46efd08
Compare
194a280 to
82e83d3
Compare
39ff9b8 to
ae5df0e
Compare

Greptile Summary
This PR successfully migrates the error handling system from
better-resulttofaultier. The refactor is complete and correctly implements the new API, including updating all error class definitions to useFaultier.Tagged, introducing fault registries for each error domain (AuthFault,EmailFault,UtilityFault), and merging them into a unifiedAppFaultregistry.Key changes:
better-resultdependency withfaultier@2.2.0inpackage.jsonimport { TaggedError } from "better-result"toimport * as Faultier from "faultier"TaggedError(...)toFaultier.Tagged(...)AuthenticationError→UnauthenticatedError,AuthorizationError→UnauthorizedError).withMessage()method callsFaultier.registry()for better error handling organizationInvalidBaseUrlErrorutility errormatchTag,matchTags,Fault) from the main indexThe 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
.withMessage()API. The changes maintain backward compatibility in terms of exported types and error behavior.Important Files Changed
better-resulttofaultier@2.2.0Faultier.Tagged, removed constructor custom messages, addedUtilityFaultregistry and newInvalidBaseUrlErrorFaultier.Tagged, fixed tag names to match class names, addedAuthFaultregistryFaultier.Taggedand addedEmailFaultregistryAppFault, exported faultier utilities (matchTag,matchTags,Fault).withMessage()method instead of passing message in constructorFlowchart
%%{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| BLast reviewed commit: ae5df0e