Skip to content
This repository was archived by the owner on Apr 3, 2024. It is now read-only.

Commit 52b5bd3

Browse files
authored
deal with source-context read errors (#242)
1 parent ce7ce0b commit 52b5bd3

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/agent/debuglet.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -342,14 +342,15 @@ Debuglet.prototype.getProjectId_ = function(callback) {
342342
Debuglet.prototype.getSourceContext_ =
343343
function(callback) {
344344
fs.readFile('source-context.json', 'utf8', function(err, data) {
345-
// TODO: deal with err here
346345
var sourceContext;
347-
try {
348-
sourceContext = JSON.parse(data);
349-
} catch (e) {
350-
err = 'Malformed source-context.json file:' + e;
351-
// But we keep on going.
346+
if (!err) {
347+
try {
348+
sourceContext = JSON.parse(data);
349+
} catch (e) {
350+
err = 'Malformed source-context.json file: ' + e;
351+
}
352352
}
353+
// We keep on going even if there are errors.
353354
return callback(err, sourceContext);
354355
});
355356
};

0 commit comments

Comments
 (0)