Include underlying error in error message
This commit is contained in:
parent
c8fb403f2f
commit
3d849e9df2
6 changed files with 23 additions and 10 deletions
8
lib/init.test.js
generated
8
lib/init.test.js
generated
|
|
@ -93,10 +93,14 @@ for (const { runnerEnv, ErrorConstructor, message } of [
|
|||
fs.mkdirSync(dbLocation, { recursive: true });
|
||||
const fileToCleanUp = path_1.default.resolve(dbLocation, "something-to-cleanup.txt");
|
||||
fs.writeFileSync(fileToCleanUp, "");
|
||||
const rmSyncError = `Failed to clean up file ${fileToCleanUp}`;
|
||||
const messages = [];
|
||||
t.throws(() => (0, init_1.cleanupDatabaseClusterDirectory)((0, testing_utils_1.createTestConfig)({ dbLocation }), (0, testing_utils_1.getRecordingLogger)(messages), () => {
|
||||
throw new Error("Failed to clean up");
|
||||
}), { instanceOf: ErrorConstructor, message: message(dbLocation) });
|
||||
throw new Error(rmSyncError);
|
||||
}), {
|
||||
instanceOf: ErrorConstructor,
|
||||
message: `${message(dbLocation)} Details: ${rmSyncError}`,
|
||||
});
|
||||
t.is(messages.length, 1);
|
||||
t.is(messages[0].type, "warning");
|
||||
t.is(messages[0].message, `The database cluster directory ${dbLocation} must be empty. Attempting to clean it up.`);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue