Skip to content

Commit

Permalink
Add guard to error variable which can sometimes be null
Browse files Browse the repository at this point in the history
  • Loading branch information
walidkayhan committed Feb 21, 2024
1 parent c809e4b commit 019f225
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/server/controllers/Grbl/GrblController.js
Original file line number Diff line number Diff line change
Expand Up @@ -770,7 +770,7 @@ class GrblController {
const line = lines[received] || '';

const preferences = store.get('preferences') || { showLineWarnings: false };
this.emit('serialport:read', `error:${code} (${error.message})`);
this.emit('serialport:read', `error:${code} (${error?.message})`);

if (error) {
if (preferences.showLineWarnings === false) {
Expand Down
4 changes: 2 additions & 2 deletions src/server/controllers/Grblhal/GrblHalController.js
Original file line number Diff line number Diff line change
Expand Up @@ -743,7 +743,7 @@ class GrblHalController {
this.emit('error', {
type: ERROR,
code: `${code}`,
description: error?.description || '',
description: _.get(error, 'description', ''),
line: line,
lineNumber: isFileError ? received + 1 : '',
origin: errorOrigin,
Expand All @@ -756,7 +756,7 @@ class GrblHalController {
const line = lines[received] || '';

const preferences = store.get('preferences') || { showLineWarnings: false };
this.emit('serialport:read', `error:${code} (${error.message})`);
this.emit('serialport:read', `error:${code} (${error?.message})`);

if (error) {
if (preferences.showLineWarnings === false) {
Expand Down

0 comments on commit 019f225

Please sign in to comment.