Skip to content

Commit

Permalink
node: ComponentDefinition::create returns now a result instead of an …
Browse files Browse the repository at this point in the history
…optional (#4622)
  • Loading branch information
FloVanGH authored Feb 15, 2024
1 parent f23c768 commit f03aedf
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions api/node/src/interpreter/component_definition.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright © SixtyFPS GmbH <info@slint.dev>
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-1.1 OR LicenseRef-Slint-commercial

use napi::Result;
use slint_interpreter::ComponentDefinition;

use super::{JsComponentInstance, JsProperty};
Expand Down Expand Up @@ -57,12 +58,8 @@ impl JsComponentDefinition {
}

#[napi]
pub fn create(&self) -> Option<JsComponentInstance> {
if let Ok(instance) = self.internal.create() {
return Some(instance.into());
}

None
pub fn create(&self) -> Result<JsComponentInstance> {
Ok(self.internal.create().map_err(|e| napi::Error::from_reason(e.to_string()))?.into())
}

#[napi(getter)]
Expand Down

0 comments on commit f03aedf

Please sign in to comment.