-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: update api and remove enum (#259)
- Loading branch information
Showing
17 changed files
with
202 additions
and
121 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { AxiosError } from "axios"; | ||
import { ModelError } from "./generated"; | ||
|
||
/** | ||
* Check if the error code originates from the API | ||
* | ||
* @param error generic error returned from fumction | ||
* @returns true if error originated from the API | ||
*/ | ||
export const isServiceApiError = (error: unknown): error is AxiosError<ModelError> => { | ||
return (error as AxiosError<ModelError>).response?.data.code !== undefined; | ||
}; | ||
|
||
/** | ||
* Get the error code from the API error | ||
* | ||
* @param error generic error returned from fumction | ||
* @returns error code (one of fields of APIErrorCodes) | ||
*/ | ||
export const getErrorCode = (error: unknown): string | undefined => { | ||
return (error as AxiosError<ModelError>).response?.data?.code; | ||
}; |
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,2 +1,3 @@ | ||
export * from "./generated"; | ||
export * from "./errors"; | ||
export * from "./errors"; | ||
export * from "./errorHelpers"; |
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,22 @@ | ||
import { AxiosError } from "axios"; | ||
import { ModelError } from "./generated"; | ||
|
||
/** | ||
* Check if the error code originates from the API | ||
* | ||
* @param error generic error returned from fumction | ||
* @returns true if error originated from the API | ||
*/ | ||
export const isServiceApiError = (error: unknown): error is AxiosError<ModelError> => { | ||
return (error as AxiosError<ModelError>).response?.data.code !== undefined; | ||
}; | ||
|
||
/** | ||
* Get the error code from the API error | ||
* | ||
* @param error generic error returned from fumction | ||
* @returns error code (one of fields of APIErrorCodes) | ||
*/ | ||
export const getErrorCode = (error: unknown): string | undefined => { | ||
return (error as AxiosError<ModelError>).response?.data?.code; | ||
}; |
Oops, something went wrong.