-
Notifications
You must be signed in to change notification settings - Fork 559
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- handles signing error in one place
- Loading branch information
Showing
5 changed files
with
67 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/** | ||
* Error type that has both a message and a status. These errors are primarily | ||
* thrown by AI services and the Octokit GitHub client. | ||
*/ | ||
export interface HttpError { | ||
message: string; | ||
status: number; | ||
} | ||
|
||
/** | ||
* Error type that has both a message and a code. These errors can be thrown | ||
* by the back end code. | ||
*/ | ||
export interface BackendError { | ||
message: string; | ||
code: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export const KNOWN_ERRORS: Record<string, string> = { | ||
'errors.commit.signing_failed': ` | ||
Commit signing failed and has now been disabled. You can configure commit signing in the project settings. | ||
Please check our [documentation](https://docs.gitbutler.com/features/virtual-branches/verifying-commits) on setting up commit signing and verification. | ||
` | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import type { HttpError, BackendError } from './error'; | ||
|
||
export function isBackendError(err: unknown): err is BackendError { | ||
return ( | ||
typeof err === 'object' && | ||
err !== null && | ||
'message' in err && | ||
typeof err.message === 'string' && | ||
'code' in err && | ||
typeof err.code === 'string' | ||
); | ||
} | ||
|
||
export function isHttpError(err: unknown): err is HttpError { | ||
return ( | ||
typeof err === 'object' && | ||
err !== null && | ||
'message' in err && | ||
typeof err.message === 'string' && | ||
'code' in err && | ||
typeof err.code === 'string' | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters