[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.
|
- Use FxHasher for internal hash-based data structures.
|
||||||
- Bump [css-minify](https://github.com/Mnwa/css-minify) to 0.3.1.
|
- Bump [css-minify](https://github.com/Mnwa/css-minify) to 0.3.1.
|
||||||
- [WASM] Add `type` and `main` fields to package.json.
|
- [WASM] Add `type` and `main` fields to package.json.
|
||||||
|
- [Node.js] Improve invalid argument type error messages.
|
||||||
|
|
||||||
## 0.10.3
|
## 0.10.3
|
||||||
|
|
||||||
|
|
|
@ -2,8 +2,12 @@ use neon::prelude::*;
|
||||||
use neon::types::buffer::TypedArray;
|
use neon::types::buffer::TypedArray;
|
||||||
|
|
||||||
fn minify(mut cx: FunctionContext) -> JsResult<JsBuffer> {
|
fn minify(mut cx: FunctionContext) -> JsResult<JsBuffer> {
|
||||||
let src = cx.argument::<JsBuffer>(0)?;
|
let Ok(src) = cx.argument::<JsBuffer>(0) else {
|
||||||
let opt = cx.argument::<JsObject>(1)?;
|
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 {
|
let cfg = minify_html::Cfg {
|
||||||
do_not_minify_doctype: opt
|
do_not_minify_doctype: opt
|
||||||
.get_opt::<JsBoolean, _, _>(&mut cx, "do_not_minify_doctype")?
|
.get_opt::<JsBoolean, _, _>(&mut cx, "do_not_minify_doctype")?
|
||||||
|
|
Loading…
Reference in New Issue