From 3fcc8fae0ea8ffc3e7addb2739efe45dcd229581 Mon Sep 17 00:00:00 2001 From: Matt Loring Date: Thu, 14 Jan 2016 14:41:01 -0800 Subject: [PATCH] Warn if malformed source-contexts is found --- lib/debuglet.js | 2 +- lib/debugletapi.js | 5 +++-- test/test-debugletapi.js | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/debuglet.js b/lib/debuglet.js index 03b9ffa0..2c8556fb 100644 --- a/lib/debuglet.js +++ b/lib/debuglet.js @@ -102,7 +102,7 @@ Debuglet.prototype.start = function() { that.logger_.info('Unique ID for this Application: ' + id); - that.debugletApi_.init(id, function(err) { + that.debugletApi_.init(id, that.logger_, function(err) { if (err) { that.logger_.error('Unable to initialize the debuglet api' + ' -- disabling debuglet', err); diff --git a/lib/debugletapi.js b/lib/debugletapi.js index d971dd08..207999d8 100644 --- a/lib/debugletapi.js +++ b/lib/debugletapi.js @@ -58,9 +58,10 @@ function DebugletApi() { * that it can be uniquely identified on the server. * @param {!string} uid unique identifier for the version of source loaded * in the client + * @param {Logger} logger a logger * @param {!function(?Error)} callback */ -DebugletApi.prototype.init = function(uid, callback) { +DebugletApi.prototype.init = function(uid, logger, callback) { var that = this; that.uid_ = uid; that.nextWaitToken_ = null; @@ -76,7 +77,7 @@ DebugletApi.prototype.init = function(uid, callback) { try { that.sourceContext_ = JSON.parse(data); } catch (e) { - // TODO: log a warning. + logger.warn('Malformed source-contexts.json file.'); // But we keep on going. } callback(null); diff --git a/test/test-debugletapi.js b/test/test-debugletapi.js index 6676b25c..1f8ce0e0 100644 --- a/test/test-debugletapi.js +++ b/test/test-debugletapi.js @@ -48,7 +48,7 @@ describe('Debuglet API', function() { }); it('should acquire the project number during init', function(done) { - debugletapi.init('uid123', function(err) { + debugletapi.init('uid123', { warn: function() {} }, function(err) { assert(!err); done(); });