Skip to content

Commit

Permalink
fix: handling of error objects
Browse files Browse the repository at this point in the history
  • Loading branch information
George Taveras committed Jan 3, 2024
1 parent e2b0097 commit d939266
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions lib/core/alerts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,21 @@ const withLogLevelsRestriction =
};

const normalizeErrorMessage = (error: string | Error) => {
if (error && error instanceof Error && "file" in error) {
const { message, file, line, column } = error as SassError;
const location = file ? ` (${file}[${line}:${column}])` : "";
if (error && error instanceof Error) {
if ("file" in error) {
const { message, file, line, column } = error as SassError;
const location = file ? ` (${file}[${line}:${column}])` : "";
const wrappedError = new Error(`SASS Error ${location}\n${message}`, {
cause: error,
});

const wrappedError = new Error(`SASS Error ${location}\n${message}`, {
cause: error,
});
wrappedError.stack = chalk.red(wrappedError.stack);

wrappedError.stack = chalk.red(wrappedError.stack);
return wrappedError;
}

const wrappedError = new Error(error.message);
wrappedError.stack = chalk.red(error.stack);
return wrappedError;
}

Expand Down

0 comments on commit d939266

Please sign in to comment.