Skip to content

Commit

Permalink
feat: log errors using console.error/warn, closes #265
Browse files Browse the repository at this point in the history
  • Loading branch information
epoberezkin committed Oct 5, 2016
1 parent dbc14d5 commit 03051f9
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions lib/dot/ref.jst
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@
{{? $refVal === undefined }}
{{ var $message = 'can\'t resolve reference ' + $schema + ' from id ' + it.baseId; }}
{{? it.opts.missingRefs == 'fail' }}
{{ console.log($message); }}
{{ console.error($message); }}
{{# def.error:'$ref' }}
{{? $breakOnError }} if (false) { {{?}}
{{?? it.opts.missingRefs == 'ignore' }}
{{ console.log($message); }}
{{ console.warn($message); }}
{{? $breakOnError }} if (true) { {{?}}
{{??}}
{{
Expand Down
2 changes: 1 addition & 1 deletion lib/dot/validate.jst
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
{{? it.opts.extendRefs == 'ignore' }}
{{
$refKeywords = false;
console.log('$ref: keywords ignored in schema at path "' + it.errSchemaPath + '"');
console.warn('$ref: keywords ignored in schema at path "' + it.errSchemaPath + '"');
}}
{{?? it.opts.extendRefs !== true }}
{{ throw new Error('$ref: validation keywords used in schema at path "' + it.errSchemaPath + '" (see option extendRefs)'); }}
Expand Down
6 changes: 3 additions & 3 deletions spec/options.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -820,9 +820,9 @@ describe('Ajv Options', function () {
function testWarning(ajv, msgPattern) {
var oldConsole;
try {
oldConsole = console.log;
oldConsole = console.warn;
var consoleMsg;
console.log = function() {
console.warn = function() {
consoleMsg = Array.prototype.join.call(arguments, ' ');
};

Expand All @@ -838,7 +838,7 @@ describe('Ajv Options', function () {
if (msgPattern) consoleMsg .should.match(msgPattern);
else should.not.exist(consoleMsg);
} finally {
console.log = oldConsole;
console.warn = oldConsole;
}
}
});
Expand Down

0 comments on commit 03051f9

Please sign in to comment.