-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
83 additions
and
86 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { HttpError as K8sHttpError } from '@kubernetes/client-node' | ||
import { HttpError as KeyCloakHttpError } from '@linode/keycloak-client-node' | ||
|
||
export class WrappedError extends Error {} | ||
|
||
export function extractError(operationName: string, error: Error): WrappedError { | ||
if (error instanceof WrappedError) return error | ||
let errorDetail: any | ||
if (error instanceof KeyCloakHttpError || error instanceof K8sHttpError) { | ||
errorDetail = `status code: ${error.statusCode} - response: ${error.body}` | ||
} else { | ||
errorDetail = error | ||
} | ||
console.error(`Error in ${operationName}:`, errorDetail) | ||
return new WrappedError(errorDetail) | ||
} |