Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VSCode compatible hyperlinks in terminal output for compilation errors #21

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions lib/Build.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.
Expand Down
19 changes: 14 additions & 5 deletions lib/util/UserInteractor.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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) {
Expand All @@ -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);
Expand All @@ -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);
Expand Down