mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-16 03:31:45 +08:00
Promises rejected properly when loading wrong content
This commit is contained in:

committed by
vakrilov

parent
4c82981430
commit
0ff8038742
@ -62,8 +62,14 @@ export function request(options: http.HttpRequestOptions): Promise<http.HttpResp
|
||||
toString: () => { return NSDataToString(data); },
|
||||
toJSON: () => { return JSON.parse(NSDataToString(data)); },
|
||||
toImage: () => {
|
||||
return new Promise<imageSource.ImageSource>((resolveImage, reject) => {
|
||||
resolveImage(imageSource.fromData(data));
|
||||
return new Promise<imageSource.ImageSource>((resolveImage, rejectImage) => {
|
||||
var img = imageSource.fromData(data);
|
||||
if (img instanceof imageSource.ImageSource) {
|
||||
resolveImage(img);
|
||||
} else {
|
||||
rejectImage(new Error("Response content may not be converted to an Image"));
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
},
|
||||
|
Reference in New Issue
Block a user