Skip to content

Commit de70d8d

Browse files
committed
feat: add error display in example
1 parent d0b128d commit de70d8d

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

example/basic.html

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -78,14 +78,18 @@
7878
useWebWorker: useWebWorker,
7979
onProgress: onProgress
8080
}
81-
imageCompression(file, options).then(function (output) {
82-
logDom.innerHTML += ', output size:' + (output.size / 1024 / 1024).toFixed(2) + 'mb'
83-
console.log('output', output)
84-
const downloadLink = URL.createObjectURL(output)
85-
logDom.innerHTML += '&nbsp;<a href="' + downloadLink + '" download="' + file.name + '">download compressed image</a>'
86-
document.getElementById('preview-after-compress').src = downloadLink
87-
return uploadToServer(output)
88-
})
81+
imageCompression(file, options)
82+
.then(function (output) {
83+
logDom.innerHTML += ', output size:' + (output.size / 1024 / 1024).toFixed(2) + 'mb'
84+
console.log('output', output)
85+
const downloadLink = URL.createObjectURL(output)
86+
logDom.innerHTML += '&nbsp;<a href="' + downloadLink + '" download="' + file.name + '">download compressed image</a>'
87+
document.getElementById('preview-after-compress').src = downloadLink
88+
return uploadToServer(output)
89+
})
90+
.catch(function (error) {
91+
alert(error.message)
92+
})
8993

9094

9195
function onProgress (p) {

example/development.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,9 @@
8787
document.getElementById('preview-after-compress').src = downloadLink
8888
return uploadToServer(output)
8989
})
90+
.catch(function (error) {
91+
alert(error.message)
92+
})
9093

9194
function onProgress (p) {
9295
console.log('onProgress', p)

0 commit comments

Comments
 (0)