Skip to content

Commit

Permalink
Include underlying error in error message
Browse files Browse the repository at this point in the history
  • Loading branch information
henrymercer committed Jun 12, 2024
1 parent c8fb403 commit 3d849e9
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 10 deletions.
4 changes: 2 additions & 2 deletions lib/init.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/init.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions lib/init.test.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/init.test.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 7 additions & 2 deletions src/init.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,17 +108,22 @@ for (const { runnerEnv, ErrorConstructor, message } of [
);
fs.writeFileSync(fileToCleanUp, "");

const rmSyncError = `Failed to clean up file ${fileToCleanUp}`;

const messages: LoggedMessage[] = [];
t.throws(
() =>
cleanupDatabaseClusterDirectory(
createTestConfig({ dbLocation }),
getRecordingLogger(messages),
() => {
throw new Error("Failed to clean up");
throw new Error(rmSyncError);
},
),
{ instanceOf: ErrorConstructor, message: message(dbLocation) },
{
instanceOf: ErrorConstructor,
message: `${message(dbLocation)} Details: ${rmSyncError}`,
},
);

t.is(messages.length, 1);
Expand Down
8 changes: 6 additions & 2 deletions src/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,13 +210,17 @@ export function cleanupDatabaseClusterDirectory(
if (isSelfHostedRunner()) {
throw new util.ConfigurationError(
`${blurb} This can happen if another process is using the directory or the directory is owned by a different user. ` +
"Please clean up the directory manually and rerun the job.",
`Please clean up the directory manually and rerun the job. Details: ${
util.wrapError(e).message
}`,
);
} else {
throw new Error(
`${blurb} This shouldn't typically happen on hosted runners. ` +
"If you are using an advanced setup, please check your workflow, otherwise we " +
"recommend rerunning the job.",
`recommend rerunning the job. Details: ${
util.wrapError(e).message
}`,
);
}
}
Expand Down

0 comments on commit 3d849e9

Please sign in to comment.