[Node.js] Improve invalid arugment type error messages (fixes #101)
This commit is contained in:
parent
9eeca7bbda
commit
02ba438f76
|
@ -5,6 +5,7 @@
|
|||
- Use FxHasher for internal hash-based data structures.
|
||||
- Bump [css-minify](https://github.com/Mnwa/css-minify) to 0.3.1.
|
||||
- [WASM] Add `type` and `main` fields to package.json.
|
||||
- [Node.js] Improve invalid argument type error messages.
|
||||
|
||||
## 0.10.3
|
||||
|
||||
|
|
|
@ -2,8 +2,12 @@ use neon::prelude::*;
|
|||
use neon::types::buffer::TypedArray;
|
||||
|
||||
fn minify(mut cx: FunctionContext) -> JsResult<JsBuffer> {
|
||||
let src = cx.argument::<JsBuffer>(0)?;
|
||||
let opt = cx.argument::<JsObject>(1)?;
|
||||
let Ok(src) = cx.argument::<JsBuffer>(0) else {
|
||||
return cx.throw_type_error("the first argument is not a Buffer");
|
||||
};
|
||||
let Ok(opt) = cx.argument::<JsObject>(1) else {
|
||||
return cx.throw_type_error("the second argument is not an object");
|
||||
};
|
||||
let cfg = minify_html::Cfg {
|
||||
do_not_minify_doctype: opt
|
||||
.get_opt::<JsBoolean, _, _>(&mut cx, "do_not_minify_doctype")?
|
||||
|
|
Loading…
Reference in New Issue