Skip to content

Commit

Permalink
Improving output error messages handling
Browse files Browse the repository at this point in the history
  • Loading branch information
PicoCreator committed Jun 2, 2022
1 parent f731844 commit acbb20e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
8 changes: 6 additions & 2 deletions src/OutputHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,12 @@ class OutputHandler {
*
* @param {String} mainError message to send
*/
outputErrorMessage(mainError) {
console.error( chalk.red(JSON.stringify(mainError)) );
errorMessage(mainError) {
let errStr = ""+mainError;
if(errStr == "[object Object]") {
errStr = JSON.stringify(mainError);
}
console.error( chalk.red(errStr) );
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/cli-command/project/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -948,7 +948,7 @@ module.exports = {
// Looks ok, lets normalized it to dataObject
argv.dataObject = JSON.stringify( dataJsonObj );
} catch(e) {
OutputHandler.outputErrorMessage(e);
OutputHandler.errorMessage(e);
OutputHandler.cliArgumentError( `Invalid format for dataObject` )
}
}
Expand Down Expand Up @@ -1014,7 +1014,7 @@ module.exports = {
// Looks ok, lets normalized it to secretObject
argv.secretObject = JSON.stringify( secretJsonObj );
} catch(e) {
console.log(e)
OutputHandler.errorMessage(e)
OutputHandler.cliArgumentError( `Invalid format for secretFile : ${secretFile}` )
}
}
Expand Down

0 comments on commit acbb20e

Please sign in to comment.