FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fix(Image): catch Response content may not be converted to an Image (… · NativeScript/NativeScript@5cd8a1f · GitHub

Commit 5cd8a1f

Browse files
authored andcommitted
fix(Image): catch Response content may not be converted to an Image (#5856)
closes NativeScript/nativescript-angular#851 closes #3381
1 parent 0c3ecbc commit 5cd8a1f

2 files changed

Lines changed: 11 additions & 3 deletions

File tree

‎tns-core-modules/http/http.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export function getJSON<T>(arg: any): Promise<T> {
3333
export function getImage(arg: any): Promise<ImageSource> {
3434
return httpRequest
3535
.request(typeof arg === "string" ? { url: arg, method: "GET" } : arg)
36-
.then(responce => responce.content.toImage());
36+
.then(response => response.content.toImage());
3737
}
3838

3939
export function getFile(arg: any, destinationFilePath?: string): Promise<any> {

‎tns-core-modules/ui/image/image-common.ts‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import { Image as ImageDefinition, Stretch } from ".";
2-
import { View, Property, InheritedCssProperty, Length, Style, Color, isIOS, booleanConverter, CSSType } from "../core/view";
2+
import { View, Property, InheritedCssProperty, Length, Style, Color, isIOS, booleanConverter, CSSType, traceEnabled, traceWrite, traceCategories } from "../core/view";
33
import { ImageAsset } from "../../image-asset";
44
import { ImageSource, fromAsset, fromNativeSource, fromUrl } from "../../image-source";
55
import { isDataURI, isFileOrResourcePath, RESOURCE_PREFIX } from "../../utils/utils";
6-
76
export * from "../core/view";
87
export { ImageSource, ImageAsset, fromAsset, fromNativeSource, fromUrl, isDataURI, isFileOrResourcePath, RESOURCE_PREFIX };
98

@@ -83,6 +82,15 @@ export abstract class ImageBase extends View implements ImageDefinition {
8382
this.imageSource = r;
8483
this.isLoading = false;
8584
}
85+
}, err => {
86+
// catch: Response content may not be converted to an Image
87+
this.isLoading = false;
88+
if (traceEnabled()) {
89+
if (typeof err === "object" && err.message) {
90+
err = err.message;
91+
}
92+
traceWrite(err, traceCategories.Debug);
93+
}
8694
});
8795
}
8896
} else if (value instanceof ImageSource) {

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL