Skip to content

Commit

Permalink
feat(all): enable error aggregation with new AggregateError
Browse files Browse the repository at this point in the history
  • Loading branch information
EisenbergEffect committed Mar 23, 2015
1 parent 59e9df5 commit 88073dd
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 5 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ This library has **NO** external dependencies.
* [aurelia-framework](https://github.com/aurelia/framework)
* [aurelia-templating](https://github.com/aurelia/templating)
* [aurelia-templating-binding](https://github.com/aurelia/templating-binding)
* [aurelia-templating-resources](https://github.com/aurelia/templating-resources)

## Platform Support

Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
"usedBy": [
"aurelia-framework",
"aurelia-templating",
"aurelia-templating-binding",
"aurelia-templating-resources"
],
"documentation": {
Expand Down
29 changes: 24 additions & 5 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,28 @@
* @module logging
*/

/**
* Creates an instance of Error that aggregates and preserves an innerError.
*
* @class AggregateError
* @constructor
*/
export function AggregateError(msg, inner) {
if (inner && inner.stack) {
msg += `\n------------------------------------------------\ninner error: ${inner.stack}`;
}

var err = new Error(msg);
if (inner) {
err.innerError = inner;
}

return err;
}

/**
* Enum specifying the levels of the logger
*
*
* @property levels
* @type Enum
* @for export
Expand All @@ -20,14 +39,14 @@ export var levels = {
debug:4
};

var loggers = {},
var loggers = {},
logLevel = levels.none,
appenders = [],
slice = Array.prototype.slice,
loggerConstructionKey = {};

function log(logger, level, args){
var i = appenders.length,
var i = appenders.length,
current;

args = slice.call(args);
Expand Down Expand Up @@ -82,7 +101,7 @@ function createLogger(id){
var logger = new Logger(id, loggerConstructionKey);

if(appenders.length) {
connectLogger(logger);
connectLogger(logger);
}

return logger;
Expand Down Expand Up @@ -182,4 +201,4 @@ export class Logger {
* @param {string} message The message to log
*/
error(){}
}
}

0 comments on commit 88073dd

Please sign in to comment.