fix(core): improve error msg for invalid KeyValueDiffer.diff arg (#15489)

Closes #15402
This commit is contained in:
Dzmitry Shylovich
2017-03-28 19:37:40 +03:00
committed by Victor Berchet
parent a5c972aa8b
commit b7fa5dec21
4 changed files with 6 additions and 6 deletions

View File

@ -157,7 +157,8 @@ export class DefaultIterableDiffer<V> implements IterableDiffer<V>, IterableChan
diff(collection: NgIterable<V>): DefaultIterableDiffer<V> {
if (collection == null) collection = [];
if (!isListLikeIterable(collection)) {
throw new Error(`Error trying to diff '${collection}'`);
throw new Error(
`Error trying to diff '${stringify(collection)}'. Only arrays and iterables are allowed`);
}
if (this.check(collection)) {

View File

@ -9,7 +9,6 @@
import {looseIdentical, stringify} from '../../util';
import {isJsObject} from '../change_detection_util';
import {ChangeDetectorRef} from '../change_detector_ref';
import {KeyValueChangeRecord, KeyValueChanges, KeyValueDiffer, KeyValueDifferFactory} from './keyvalue_differs';
@ -82,7 +81,8 @@ export class DefaultKeyValueDiffer<K, V> implements KeyValueDiffer<K, V>, KeyVal
if (!map) {
map = new Map();
} else if (!(map instanceof Map || isJsObject(map))) {
throw new Error(`Error trying to diff '${map}'`);
throw new Error(
`Error trying to diff '${stringify(map)}'. Only maps and objects are allowed`);
}
return this.check(map) ? this : null;