Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโ€™ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove usage of snippet and just return a vanilla error #1140

Merged
merged 1 commit into from
Oct 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
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 @@

// 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 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
}
}
Loading