-
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.
feat: make components more robust in case of store/api errors (#160)
- Loading branch information
Showing
11 changed files
with
325 additions
and
107 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/** Common code for reev-frontend-lib/api */ | ||
|
||
/** | ||
* Thrown on API configuration errors. | ||
* | ||
* Such configuration errors are programming errors, e.g., when the | ||
* API base URL is not configured. | ||
*/ | ||
export class ConfigError extends Error { | ||
constructor(message: string) { | ||
super(message) | ||
this.name = 'ConfigurationError' | ||
} | ||
} | ||
|
||
/** | ||
* Thrown when the query to the API failed. | ||
*/ | ||
export class CallError extends Error { | ||
constructor(message: string) { | ||
super(message) | ||
this.name = 'ApiCallError' | ||
} | ||
} | ||
|
||
/** | ||
* Thrown when the API returned a non-OK status code (not 2xx). | ||
*/ | ||
export class StatusCodeNotOk extends CallError { | ||
constructor(message: string) { | ||
super(message) | ||
this.name = 'StatusCodeNotOk' | ||
} | ||
} | ||
|
||
/** | ||
* Thrown when the resulting result was improperly formatted. | ||
* | ||
* E.g., when it was not valid JSON or did not have the expected | ||
* structure. | ||
*/ | ||
export class InvalidResponseContent extends CallError { | ||
constructor(message: string) { | ||
super(message) | ||
this.name = 'InvalidResponseContent' | ||
} | ||
} |
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 |
---|---|---|
@@ -1,8 +1,9 @@ | ||
import * as annonars from './annonars' | ||
import * as cadaPrio from './cadaPrio' | ||
import * as common from './common' | ||
import * as dotty from './dotty' | ||
import * as mehari from './mehari' | ||
import * as pubtator from './pubtator' | ||
import * as variantValidator from './variantValidator' | ||
|
||
export { annonars, cadaPrio, dotty, mehari, pubtator, variantValidator } | ||
export { annonars, cadaPrio, common, dotty, mehari, pubtator, variantValidator } |
Oops, something went wrong.