{"record":{"id":"89358d0c3712dd8f","repo":"slint-ui/slint","slug":"expect-number-got-vt","errorCode":null,"errorMessage":"expect Number, got: {vt:?}","messagePattern":"expect Number, got: (.+?)","errorType":"exception","errorClass":"napi::Error","httpStatus":null,"severity":"error","filePath":"api/node/rust/interpreter/value.rs","lineNumber":33,"sourceCode":"use slint_interpreter::Value;\nuse smol_str::SmolStr;\n\n/// A dynamic-length argument list for calling JS functions with a variable\n/// number of arguments. Implements `JsValuesTupleIntoVec` so it can be used\n/// directly with `Function::call`.\npub struct DynArgs(pub Vec<napi::sys::napi_value>);\n\nimpl JsValuesTupleIntoVec for DynArgs {\n    fn into_vec(self, _env: napi::sys::napi_env) -> Result<Vec<napi::sys::napi_value>> {\n        Ok(self.0)\n    }\n}\n\n/// Safely extract a f64 from an Unknown, failing if the type is wrong.\nfn expect_number(unknown: Unknown<'_>) -> Result<f64> {\n    match unknown.get_type()? {\n        ValueType::Number => unknown.coerce_to_number()?.get_double(),\n        vt => Err(napi::Error::new(\n            napi::Status::NumberExpected,\n            format!(\"expect Number, got: {vt:?}\"),\n        )),\n    }\n}\n\n/// Safely extract a String from an Unknown, failing if the type is wrong.\nfn expect_string(unknown: Unknown<'_>) -> Result<String> {\n    match unknown.get_type()? {\n        ValueType::String => Ok(unknown.coerce_to_string()?.into_utf8()?.as_str()?.to_owned()),\n        vt => Err(napi::Error::new(\n            napi::Status::StringExpected,\n            format!(\"expect String, got: {vt:?}\"),\n        )),\n    }\n}\n\n/// Safely extract a bool from an Unknown, failing if the type is wrong.","sourceCodeStart":15,"sourceCodeEnd":51,"githubUrl":"https://github.com/slint-ui/slint/blob/3fd8f2ec03c2aa8a95d5f4b9daa299c7b8bf4016/api/node/rust/interpreter/value.rs#L15-L51","documentation":"Error \"expect Number, got: {vt:?}\" thrown in slint-ui/slint.","triggerScenarios":"Thrown at api/node/rust/interpreter/value.rs:33 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass a JavaScript number where the Slint value expects a Number.","Convert the value with Number() before passing it."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"3fd8f2ec03c2aa8a95d5f4b9daa299c7b8bf4016","analyzedAt":"2026-08-19T23:23:16.610Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}