Skip to content

Commit

Permalink
Merge pull request #505 from GrimoireGL/feat/removeComponents
Browse files Browse the repository at this point in the history
fix: error message of converting attribute
  • Loading branch information
kyasbal committed Jul 9, 2017
2 parents 064f0a7 + 165d610 commit eacfc95
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
10 changes: 5 additions & 5 deletions package.json
Expand Up @@ -13,7 +13,7 @@
"grimoire"
],
"dependencies": {
"@types/node": "^8.0.5",
"@types/node": "^8.0.9",
"events": "^1.1.1"
},
"devDependencies": {
Expand All @@ -28,7 +28,7 @@
"condition-circle": "^1.5.0",
"cpx": "^1.5.0",
"grimoirejs-cauldron": "^3.1.5",
"jsdom": "^11.0.0",
"jsdom": "^11.1.0",
"lodash": "^4.17.2",
"nyc": "^11.0.3",
"proxyquire": "^1.7.11",
Expand All @@ -37,13 +37,13 @@
"semantic-release": "^6.3.2",
"sinon": "^2.3.6",
"trash-cli": "^1.4.0",
"ts-loader": "^2.2.1",
"tslint": "^5.4.3",
"ts-loader": "^2.2.2",
"tslint": "^5.5.0",
"typedoc": "^0.7.0",
"typedoc-md-theme": "^1.0.1",
"typescript": "^2.4.1",
"typescript-awaiter": "^1.0.0",
"webpack": "^3.0.0",
"webpack": "^3.1.0",
"webpack-shell-plugin": "^0.5.0",
"xhr-mock": "^1.7.0",
"xmldom": "^0.1.27",
Expand Down
3 changes: 1 addition & 2 deletions src/Base/IdResolver.ts
Expand Up @@ -93,11 +93,11 @@ export default class IdResolver {
}

private _get(name: string[]): string[][] {
const res: string[][] = [];
if (name.length === 0) {
if (this.count === 0) {
return [[]];
}
const res: string[][] = [];
for (let key in this._nameMap) {
let match = this._nameMap[key]._get([])!;
for (let i = 0; i < match.length; i++) {
Expand All @@ -112,7 +112,6 @@ export default class IdResolver {
return res;
}
let current_name = name[name.length - 1];
const res: string[][] = [];
for (let key in this._nameMap) {
let match = key === current_name ? this._nameMap[key]._get(name.slice(0, name.length - 1)) : this._nameMap[key]._get(name);
if (match.length !== 0) {
Expand Down
21 changes: 11 additions & 10 deletions src/Node/Attribute.ts
Expand Up @@ -240,30 +240,31 @@ export default class Attribute {
private _valuate(raw: any): any {
const v = this.converter.convert(raw, this);
if (v === void 0) {
throw new Error(`attribute ${this.name.name} value can not be convert from ${this._value}`);
const errorMessage = `Converting attribute value failed.\n\n* input : ${raw}\n* Attribute(Attribute FQN) : ${this.name.name}(${this.name.fqn})\n* Component : ${this.component.name.name}(${this.component.name.fqn})\n* Node(Node FQN) : ${this.component.node.name.name}(${this.component.node.name.fqn})\n* Converter : ${this.declaration.converter}\n\n* Structure map:\n${this.component.node.toStructualString(`--------------Error was thrown from '${this.name.name}' of this node.`)}`;
throw new Error(errorMessage);
}
this._lastValuete = v;
return v;
}

private _notifyChange(newValue: any): void {
const lastvalue = this._lastValuete;
if (!this.component.isActive) {
if (this._ignoireActivenessObservers.length === 0) {
return;
}
const lastvalue = this._lastValuete;
const convertedNewValue = this._valuate(newValue);
this._ignoireActivenessObservers.forEach((watcher) => {
watcher(convertedNewValue, lastvalue, this);
});
} else {
const convertedNewValue = this._valuate(newValue);
this._observers.forEach((watcher) => {
watcher(convertedNewValue, lastvalue, this);
});
this._ignoireActivenessObservers.forEach((watcher) => {
watcher(convertedNewValue, lastvalue, this);
});
}
const lastvalue = this._lastValuete;
const convertedNewValue = this._valuate(newValue);
this._observers.forEach((watcher) => {
watcher(convertedNewValue, lastvalue, this);
});
this._ignoireActivenessObservers.forEach((watcher) => {
watcher(convertedNewValue, lastvalue, this);
});
}
}

0 comments on commit eacfc95

Please sign in to comment.