Skip to content

Commit

Permalink
Remove usage of snippet and just return a vanilla error (#1140)
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

## 🎟️ Tracking

<!-- Paste the link to the Jira or GitHub issue or otherwise describe /
point to where this change is coming from. -->

## 📔 Objective

Snippets are not properly uploaded to npmjs. Bypassing the issue by not
using snippets until we figure out error handling properly

## ⏰ Reminders before review

- Contributor guidelines followed
- All formatters and local linters executed and passed
- Written new unit and / or integration tests where applicable
- Protected functional changes with optionality (feature flags)
- Used internationalization (i18n) for all UI strings
- CI builds passed
- Communicated to DevOps any deployment requirements
- Updated any necessary documentation (Confluence, contributing docs) or
informed the documentation
  team

## 🦮 Reviewer guidelines

<!-- Suggested interactions but feel free to use (or not) as you desire!
-->

- 👍 (`:+1:`) or similar for great changes
- 📝 (`:memo:`) or ℹ️ (`:information_source:`) for notes or general info
- ❓ (`:question:`) for questions
- 🤔 (`:thinking:`) or 💭 (`:thought_balloon:`) for more open inquiry
that's not quite a confirmed
  issue and could potentially benefit from discussion
- 🎨 (`:art:`) for suggestions / improvements
- ❌ (`:x:`) or ⚠️ (`:warning:`) for more significant problems or
concerns needing attention
- 🌱 (`:seedling:`) or ♻️ (`:recycle:`) for future improvements or
indications of technical debt
- ⛏ (`:pick:`) for minor or nitpick changes
  • Loading branch information
coroiu authored Oct 14, 2024
1 parent c22c216 commit 8b44f55
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))
}

/// 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()
}
}

0 comments on commit 8b44f55

Please sign in to comment.