refs #1225 Catch error when can not load image in exifImageUrl

This commit is contained in:
AkiraFukushima 2020-01-14 00:53:35 +09:00
parent 77f5dfb65c
commit 79ba8ecbad
2 changed files with 6 additions and 3 deletions

View File

@ -50,7 +50,7 @@ export default {
const transformed = await exifImageUrl(this.src)
this.originalSrc = transformed
} catch (err) {
console.error(err)
console.warn(err)
}
}
},
@ -62,7 +62,7 @@ export default {
const transformed = await exifImageUrl(newSrc)
this.originalSrc = transformed
} catch (err) {
console.error(err)
console.warn(err)
}
}
}

View File

@ -22,11 +22,14 @@ const exifImageUrl = url => {
return new Promise((resolve, reject) => {
const extension = parseExtension(url)
if (!extension) {
reject(Error(`url is not image: ${url}`))
return reject(Error(`url is not image: ${url}`))
}
loadImage(
url,
canvas => {
if (canvas.type === 'error') {
return reject(Error(`can not load image: ${url}`))
}
const data = canvas.toDataURL(extension)
resolve(data)
},