-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: do not print generic error message for expected errors (#110)
* fix: do not print generic error message for expected errors * extract cycli error cancel to consts and reuse
- Loading branch information
Showing
11 changed files
with
75 additions
and
40 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
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
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
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
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
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,26 @@ | ||
import { CYCLI_ERROR_NAME } from '../constants' | ||
|
||
export const isError = (e: unknown): boolean => { | ||
return Boolean( | ||
typeof e === 'object' && | ||
e != null && | ||
'message' in e && | ||
typeof e.message === 'string' && | ||
'name' in e && | ||
typeof e.name === 'string' | ||
) | ||
} | ||
|
||
export const isCycliError = (e: unknown): boolean => { | ||
return isError(e) && (e as Error).name === CYCLI_ERROR_NAME | ||
} | ||
|
||
export const messageFromError = (e: unknown): string => { | ||
if (isError(e)) { | ||
return (e as Error).message | ||
} | ||
|
||
// This should normally never be reached, but since you can throw anything | ||
// and errors have unknown type, we have to handle every case. | ||
return JSON.stringify(e) | ||
} |
This file was deleted.
Oops, something went wrong.