mirror of
https://github.com/github/codeql-action.git
synced 2026-10-31 09:59:43 +00:00
Move wrapError and getErrorMessage out of util.ts
This commit is contained in:
18
src/util.ts
18
src/util.ts
@@ -23,12 +23,12 @@ import {
|
||||
getEnv,
|
||||
type Env,
|
||||
} from "./environment";
|
||||
import { ConfigurationError } from "./errors";
|
||||
import { ConfigurationError, getErrorMessage, wrapError } from "./errors";
|
||||
import { Language } from "./languages";
|
||||
import { Logger } from "./logging";
|
||||
|
||||
// Re-export for backwards compatibility to avoid updating a lot of imports elsewhere.
|
||||
export { ConfigurationError, HTTPError, asHTTPError } from "./errors";
|
||||
export * from "./errors";
|
||||
export {
|
||||
getRequiredEnvParam,
|
||||
getOptionalEnvVar,
|
||||
@@ -839,20 +839,6 @@ export function parseMatrixInput(
|
||||
}
|
||||
}
|
||||
|
||||
export function wrapError(error: unknown): Error {
|
||||
return error instanceof Error ? error : new Error(String(error));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an appropriate message for the error.
|
||||
*
|
||||
* If the error is an `Error` instance, this returns the error message without
|
||||
* an `Error: ` prefix.
|
||||
*/
|
||||
export function getErrorMessage(error: unknown): string {
|
||||
return error instanceof Error ? error.message : String(error);
|
||||
}
|
||||
|
||||
export function prettyPrintPack(pack: Pack) {
|
||||
return `${pack.name}${pack.version ? `@${pack.version}` : ""}${
|
||||
pack.path ? `:${pack.path}` : ""
|
||||
|
||||
Reference in New Issue
Block a user