mirror of
https://github.com/gabehf/Tdarr_Plugins.git
synced 2026-03-16 02:35:54 -07:00
Stack log errors
This commit is contained in:
parent
2818e8019e
commit
1ebc300805
1 changed files with 12 additions and 3 deletions
|
|
@ -6,6 +6,15 @@ const os = require('os');
|
||||||
|
|
||||||
const scriptName = path.basename(process.mainModule.filename);
|
const scriptName = path.basename(process.mainModule.filename);
|
||||||
|
|
||||||
|
const stackLog = (err) => {
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
|
console.log(err);
|
||||||
|
if (err.stack) {
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
|
console.log(JSON.stringify(err.stack));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const run = async (tests) => {
|
const run = async (tests) => {
|
||||||
try {
|
try {
|
||||||
for (let i = 0; i < tests.length; i += 1) {
|
for (let i = 0; i < tests.length; i += 1) {
|
||||||
|
|
@ -48,13 +57,13 @@ const run = async (tests) => {
|
||||||
|
|
||||||
if (test?.error?.shouldThrow) {
|
if (test?.error?.shouldThrow) {
|
||||||
if (errorEncountered !== false) {
|
if (errorEncountered !== false) {
|
||||||
// eslint-disable-next-line no-console
|
stackLog(errorEncountered);
|
||||||
console.log(errorEncountered);
|
|
||||||
chai.assert.deepEqual(errorEncountered.message, expectedOutput);
|
chai.assert.deepEqual(errorEncountered.message, expectedOutput);
|
||||||
} else {
|
} else {
|
||||||
throw new Error('Expected plugin error but none was thrown!');
|
throw new Error('Expected plugin error but none was thrown!');
|
||||||
}
|
}
|
||||||
} else if (!test?.error?.shouldThrow && errorEncountered !== false) {
|
} else if (!test?.error?.shouldThrow && errorEncountered !== false) {
|
||||||
|
stackLog(errorEncountered);
|
||||||
throw new Error(`Unexpected plugin error!${errorEncountered}`);
|
throw new Error(`Unexpected plugin error!${errorEncountered}`);
|
||||||
} else {
|
} else {
|
||||||
chai.assert.deepEqual(testOutput, expectedOutput);
|
chai.assert.deepEqual(testOutput, expectedOutput);
|
||||||
|
|
@ -63,7 +72,7 @@ const run = async (tests) => {
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
// eslint-disable-next-line no-console
|
// eslint-disable-next-line no-console
|
||||||
console.error(err);
|
stackLog(err);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue