Skip to content

Commit

Permalink
feat(twconf): Use eerror in twconf class (index.js).
Browse files Browse the repository at this point in the history
  • Loading branch information
CheerlessCloud committed Aug 14, 2017
1 parent 4e9c440 commit 626b3ba
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import EError from 'eerror';
import * as Types from './types';
import ConfigField from './config-field';
import envParser from './env-parser';
Expand Down Expand Up @@ -66,9 +67,9 @@ class TwConf {
this.skeleton.forEach((value, key) => {
if (!(value instanceof ConfigField)) {
if (typeof value !== 'object') {
const err = new TypeError('Value of ConfigRule must be a object');
err.field = key;
throw err;
throw new EError('Config rule must be an object', {
field: key,
});
}

this.skeleton.set(key, new ConfigField(value));
Expand Down Expand Up @@ -101,9 +102,7 @@ class TwConf {
});

if (errors.length) {
const newError = new Error('Validation errors');
newError.errors = errors;
throw newError;
throw new EError('Validation errors', { errors });
}
}
}
Expand Down

0 comments on commit 626b3ba

Please sign in to comment.