Skip to content

Commit

Permalink
fix: remove usage of snipper and just return a vanilla error
Browse files Browse the repository at this point in the history
we'll have to look into proper error handling anyways, so I'm just quickfixing this until then
  • Loading branch information
coroiu committed Oct 14, 2024
1 parent d094901 commit c3016be
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 18 deletions.
4 changes: 4 additions & 0 deletions crates/bitwarden-wasm-internal/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ impl BitwardenClient {
msg
}

pub fn throw(&self, msg: String) -> Result<(), crate::error::GenericError> {
Err(crate::error::GenericError(msg))
}

Check warning on line 54 in crates/bitwarden-wasm-internal/src/client.rs

View check run for this annotation

Codecov / codecov/patch

crates/bitwarden-wasm-internal/src/client.rs#L52-L54

Added lines #L52 - L54 were not covered by tests

/// Test method, calls http endpoint
pub async fn http_get(&self, url: String) -> Result<String, String> {
let client = self.0.internal.get_http_client();
Expand Down
13 changes: 0 additions & 13 deletions crates/bitwarden-wasm-internal/src/error.js

This file was deleted.

11 changes: 6 additions & 5 deletions crates/bitwarden-wasm-internal/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ use wasm_bindgen::prelude::*;

// Importing an error class defined in JavaScript instead of defining it in Rust
// allows us to extend the `Error` class. It also provides much better console output.
#[wasm_bindgen(module = "/src/error.js")]
#[wasm_bindgen]
extern "C" {
type WasmError;
#[wasm_bindgen(js_name = Error)]
type JsError;

#[wasm_bindgen(constructor)]
fn new(message: String) -> WasmError;
#[wasm_bindgen(constructor, js_class = Error)]
fn new(message: String) -> JsError;
}

pub type Result<T, E = GenericError> = std::result::Result<T, E>;
Expand All @@ -22,6 +23,6 @@ impl<T: ToString> From<T> for GenericError {

impl From<GenericError> for JsValue {
fn from(error: GenericError) -> Self {
WasmError::new(error.0).into()
JsError::new(error.0).into()

Check warning on line 26 in crates/bitwarden-wasm-internal/src/error.rs

View check run for this annotation

Codecov / codecov/patch

crates/bitwarden-wasm-internal/src/error.rs#L26

Added line #L26 was not covered by tests
}
}

0 comments on commit c3016be

Please sign in to comment.