fix(Image): catch Response content may not be converted to an Image (#5856)

closes https://github.com/NativeScript/nativescript-angular/issues/851
closes https://github.com/NativeScript/NativeScript/issues/3381
This commit is contained in:
Nathan Walker
2018-06-13 03:45:54 -07:00
committed by Alexander Vakrilov
parent 0c3ecbc57b
commit 5cd8a1fc2a
2 changed files with 11 additions and 3 deletions

View File

@@ -1,9 +1,8 @@
import { Image as ImageDefinition, Stretch } from ".";
import { View, Property, InheritedCssProperty, Length, Style, Color, isIOS, booleanConverter, CSSType } from "../core/view";
import { View, Property, InheritedCssProperty, Length, Style, Color, isIOS, booleanConverter, CSSType, traceEnabled, traceWrite, traceCategories } from "../core/view";
import { ImageAsset } from "../../image-asset";
import { ImageSource, fromAsset, fromNativeSource, fromUrl } from "../../image-source";
import { isDataURI, isFileOrResourcePath, RESOURCE_PREFIX } from "../../utils/utils";
export * from "../core/view";
export { ImageSource, ImageAsset, fromAsset, fromNativeSource, fromUrl, isDataURI, isFileOrResourcePath, RESOURCE_PREFIX };
@@ -83,6 +82,15 @@ export abstract class ImageBase extends View implements ImageDefinition {
this.imageSource = r;
this.isLoading = false;
}
}, err => {
// catch: Response content may not be converted to an Image
this.isLoading = false;
if (traceEnabled()) {
if (typeof err === "object" && err.message) {
err = err.message;
}
traceWrite(err, traceCategories.Debug);
}
});
}
} else if (value instanceof ImageSource) {