Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions packages/logging/src/log.js
Original file line number Diff line number Diff line change
Expand Up @@ -630,9 +630,17 @@ Log.prototype.decorateEntries_ = function(entries, callback) {
entry = self.entry(entry);
}

var decoratedEntry = entry.toJSON({
removeCircular: self.removeCircular_
});
var decoratedEntry;

try {
decoratedEntry = entry.toJSON({
removeCircular: self.removeCircular_
});
} catch(e) {
callback(e);
return;
}

decoratedEntry.logName = self.formattedName_;

self.metadata_.assignDefaultResource(decoratedEntry, function(err, entry) {
Expand Down
14 changes: 14 additions & 0 deletions packages/logging/test/log.js
Original file line number Diff line number Diff line change
Expand Up @@ -696,6 +696,20 @@ describe('Log', function() {
log.decorateEntries_([entry], assert.ifError);
});

it('should exec callback with error from serialization', function(done) {
var error = new Error('Error.');

var entry = new Entry();
entry.toJSON = function() {
throw error;
};

log.decorateEntries_([entry], function(err) {
assert.strictEqual(err, error);
done();
});
});

it('should assign the log name', function(done) {
log.decorateEntries_([{}], function(err, decoratedEntries) {
assert.ifError(err);
Expand Down