Skip to content

Commit

Permalink
Improve logging and error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
sheyabernstein committed Feb 28, 2024
1 parent 32f43ad commit 7c87ed3
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions node_helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ module.exports = NodeHelper.create({
try {
const response = await fetch(url, { headers });
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
Log.error(`${this.name}: HTTP ${response.status}`);
}
if (
response.headers
Expand All @@ -76,12 +76,12 @@ module.exports = NodeHelper.create({
const data = await response.json();
self.sendSocketNotification(notification, data);
} else {
throw new Error(
`Expected JSON but received ${response.headers.get("content-type")}`,
Log.error(
`${this.name}: Expected JSON but received ${response.headers.get("content-type")}`,
);
}
} catch (error) {
Log.error(self.name + " ERROR:", error);
Log.error(`${this.name}: ${error}`)
}
},
});

0 comments on commit 7c87ed3

Please sign in to comment.