diff --git a/lib/Build.js b/lib/Build.js index 6ae812e9..83261268 100644 --- a/lib/Build.js +++ b/lib/Build.js @@ -139,7 +139,7 @@ class Build extends Entity { deploy(options) { this._deploy(options). then(() => UserInteractor.printSuccessStatus()). - catch(error => UserInteractor.processError(error)); + catch(error => UserInteractor.processError(error, this._agentFileName, this._deviceFileName)); } // Creates, deploys and run a build or reports an error occurred. @@ -164,7 +164,9 @@ class Build extends Entity { UserInteractor.printSuccessStatus(); } }). - catch(error => UserInteractor.processError(error)); + catch(error => { + UserInteractor.processError(error, this._agentFileName, this._deviceFileName) + }); } // Updates tags of the current Build. diff --git a/lib/util/UserInteractor.js b/lib/util/UserInteractor.js index 0c2efdfe..4c10eb53 100644 --- a/lib/util/UserInteractor.js +++ b/lib/util/UserInteractor.js @@ -260,7 +260,7 @@ class UserInteractor { console.log(jsonFormatter.render(data)); } - static processError(error) { + static processError(error, agentFileName, deviceFileName) { UserInteractor.spinnerStop(); if (UserInteractor.debug) { UserInteractor.printMessage(error); @@ -341,7 +341,7 @@ class UserInteractor { UserInteractor.printErrorStatus(); } else if (error instanceof ImpCentralApi.Errors.ImpCentralApiError) { - UserInteractor.printImpCentralApiError(error); + UserInteractor.printImpCentralApiError(error, agentFileName, deviceFileName); UserInteractor.printErrorStatus(); } else if (error instanceof ImpCentralApi.Errors.InvalidDataError) { @@ -359,9 +359,9 @@ class UserInteractor { } } - static printImpCentralApiError(error) { + static printImpCentralApiError(error, agentFileName, deviceFileName) { if (error.body && error.body.hasOwnProperty('errors')) { - UserInteractor._printErrorsAndWarnings(error.body.errors); + UserInteractor._printErrorsAndWarnings(error.body.errors, agentFileName, deviceFileName); } else { UserInteractor.printError(error.message); @@ -374,10 +374,19 @@ class UserInteractor { } } - static _printErrorsAndWarnings(entities) { + static _printErrorsAndWarnings(entities, agentFileName, deviceFileName) { if (Array.isArray(entities)) { + entities.forEach((entity) => { if (['title', 'detail', 'status'].every(prop => entity.hasOwnProperty(prop))) { + + if(entity.title === "Compilation Error"){ + entity.meta.forEach((meta) => { + var file = meta.file === "agent_code" ? agentFileName : deviceFileName + UserInteractor.printMessage(file + ":" + meta.row + ":" + meta.column) + }) + } + const message = entity.title + ': ' + entity.detail; if (UserInteractor._isError(entity)) { UserInteractor.printError(message);