fix: reject a promise with an error object

- resolve "Unhandled promise rejection" error
- https://stackoverflow.com/a/47803880
This commit is contained in:
curbengh 2019-12-27 04:30:10 +00:00
parent 9df4e8283b
commit 932d36182c
No known key found for this signature in database
GPG Key ID: 21EA847C35D6E034
1 changed files with 3 additions and 6 deletions

View File

@ -120,8 +120,7 @@ function minifySvg () {
if (options.logger) verbose.call(this, assetTxt, data, path, 'svg') if (options.logger) verbose.call(this, assetTxt, data, path, 'svg')
resolve(route.set(path, data)) resolve(route.set(path, data))
} catch (err) { } catch (err) {
reject(err) reject(new Error(err))
throw new Error(err)
} }
} }
}) })
@ -156,8 +155,7 @@ function gzipFn () {
if (options.logger) verbose.call(this, input, result, path, 'gzip') if (options.logger) verbose.call(this, input, result, path, 'gzip')
resolve(route.set(path + '.gz', result)) resolve(route.set(path + '.gz', result))
} catch (err) { } catch (err) {
reject(err) reject(new Error(err))
throw new Error(err)
} }
} }
}) })
@ -191,8 +189,7 @@ function brotliFn () {
if (options.logger) verbose.call(this, input, result, path, 'brotli') if (options.logger) verbose.call(this, input, result, path, 'brotli')
resolve(route.set(path + '.br', result)) resolve(route.set(path + '.br', result))
} catch (err) { } catch (err) {
reject(err) reject(new Error(err))
throw new Error(err)
} }
} }
}) })