Fix: drop __ERROR__

This commit is contained in:
eight 2018-10-14 02:43:52 +08:00
parent 838c21e3b3
commit 90aadfd728

View File

@ -203,24 +203,18 @@
function getResource(url, options) { function getResource(url, options) {
return new Promise(resolve => {
if (url.startsWith('#')) { if (url.startsWith('#')) {
resolve(document.getElementById(url.slice(1)).textContent); return Promise.resolve(document.getElementById(url.slice(1)).textContent);
} else { }
API.download(Object.assign({ return API.download(Object.assign({
url, url,
timeout: 60e3, timeout: 60e3,
// USO can't handle POST requests for style json // USO can't handle POST requests for style json
body: null, body: null,
}, options)).then(result => { }, options))
const error = result && result.__ERROR__; .catch(error => {
if (error) {
alert('Error' + (error ? '\n' + error : '')); alert('Error' + (error ? '\n' + error : ''));
} else { throw error;
resolve(result);
}
});
}
}); });
} }