Skip to content

Commit 5ddab1d

Browse files
committed
Remove gRPC error code from error notifications
1 parent f0d9894 commit 5ddab1d

File tree

5 files changed

+53
-9
lines changed

5 files changed

+53
-9
lines changed

Diff for: arduino-ide-extension/src/browser/contributions/burn-bootloader.ts

+7-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,13 @@ export class BurnBootloader extends SketchContribution {
7979
}
8080
);
8181
} catch (e) {
82-
this.messageService.error(e.toString());
82+
let errorMessage = "";
83+
if (typeof e === "string") {
84+
errorMessage = e;
85+
} else {
86+
errorMessage = e.toString();
87+
}
88+
this.messageService.error(errorMessage);
8389
} finally {
8490
if (this.serialConnection.isSerialOpen()) {
8591
await this.serialConnection.connect();

Diff for: arduino-ide-extension/src/browser/contributions/upload-sketch.ts

+7-1
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,13 @@ export class UploadSketch extends SketchContribution {
277277
{ timeout: 3000 }
278278
);
279279
} catch (e) {
280-
this.messageService.error(e.toString());
280+
let errorMessage = "";
281+
if (typeof e === "string") {
282+
errorMessage = e;
283+
} else {
284+
errorMessage = e.toString();
285+
}
286+
this.messageService.error(errorMessage);
281287
} finally {
282288
this.uploadInProgress = false;
283289
this.onDidChangeEmitter.fire();

Diff for: arduino-ide-extension/src/browser/contributions/verify-sketch.ts

+7-1
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,13 @@ export class VerifySketch extends SketchContribution {
127127
{ timeout: 3000 }
128128
);
129129
} catch (e) {
130-
this.messageService.error(e.toString());
130+
let errorMessage = "";
131+
if (typeof e === "string") {
132+
errorMessage = e;
133+
} else {
134+
errorMessage = e.toString();
135+
}
136+
this.messageService.error(errorMessage);
131137
} finally {
132138
this.verifyInProgress = false;
133139
this.onDidChangeEmitter.fire();

Diff for: arduino-ide-extension/src/node/core-service-impl.ts

+23-6
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import { NotificationServiceServer } from '../common/protocol';
2323
import { ArduinoCoreServiceClient } from './cli-protocol/cc/arduino/cli/commands/v1/commands_grpc_pb';
2424
import { firstToUpperCase, firstToLowerCase } from '../common/utils';
2525
import { Port } from './cli-protocol/cc/arduino/cli/commands/v1/port_pb';
26+
import { nls } from '@theia/core';
2627

2728
@injectable()
2829
export class CoreServiceImpl extends CoreClientAware implements CoreService {
@@ -85,11 +86,16 @@ export class CoreServiceImpl extends CoreClientAware implements CoreService {
8586
chunk: '\n--------------------------\nCompilation complete.\n',
8687
});
8788
} catch (e) {
89+
const errorMessage = nls.localize(
90+
'arduino/compile/error',
91+
'Compilation error: {0}',
92+
e.details
93+
);
8894
this.responseService.appendToOutput({
89-
chunk: `Compilation error: ${e.details}\n`,
95+
chunk: `${errorMessage}}\n`,
9096
severity: 'error',
9197
});
92-
throw e;
98+
throw new Error(errorMessage);
9399
}
94100
}
95101

@@ -180,11 +186,17 @@ export class CoreServiceImpl extends CoreClientAware implements CoreService {
180186
' complete.\n',
181187
});
182188
} catch (e) {
189+
const errorMessage = nls.localize(
190+
'arduino/upload/error',
191+
'{0} error: {1}',
192+
firstToUpperCase(task),
193+
e.details,
194+
);
183195
this.responseService.appendToOutput({
184-
chunk: `${firstToUpperCase(task)} error: ${e.details}\n`,
196+
chunk: `${errorMessage}\n`,
185197
severity: 'error',
186198
});
187-
throw e;
199+
throw new Error(errorMessage);
188200
} finally {
189201
this.uploading = false;
190202
}
@@ -227,11 +239,16 @@ export class CoreServiceImpl extends CoreClientAware implements CoreService {
227239
result.on('end', () => resolve());
228240
});
229241
} catch (e) {
242+
const errorMessage = nls.localize(
243+
'arduino/burnBootloader/error',
244+
'Error while burning the bootloader: {0}',
245+
e.details,
246+
);
230247
this.responseService.appendToOutput({
231-
chunk: `Error while burning the bootloader: ${e.details}\n`,
248+
chunk: `${errorMessage}\n`,
232249
severity: 'error',
233250
});
234-
throw e;
251+
throw new Error(errorMessage);
235252
}
236253
}
237254

Diff for: i18n/en.json

+9
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,15 @@
288288
"electron": {
289289
"couldNotSave": "Could not save the sketch. Please copy your unsaved work into your favorite text editor, and restart the IDE.",
290290
"unsavedChanges": "Any unsaved changes will not be saved."
291+
},
292+
"compile": {
293+
"error": "Compilation error: {0}"
294+
},
295+
"upload": {
296+
"error": "{0} error: {1}"
297+
},
298+
"burnBootloader": {
299+
"error": "Error while burning the bootloader: {0}"
291300
}
292301
},
293302
"theia": {

0 commit comments

Comments
 (0)