1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// SPDX-FileCopyrightText: 2025 RAprogramm <andrey.rozanov.vl@gmail.com>
//
// SPDX-License-Identifier: MIT
//! Browser/WASM helpers for converting application errors into JavaScript
//! values.
//!
//! This module is available when the `frontend` feature is enabled. It provides
//! helpers to serialize [`crate::AppError`] and [`crate::ErrorResponse`] into
//! [`wasm_bindgen::JsValue`] and optionally emit structured logs via
//! `console.error` when running inside a browser.
//!
//! # Examples
//!
//! ```rust
//! # #[cfg(feature = "frontend")]
//! # {
//! use masterror::{
//! AppError,
//! frontend::{BrowserConsoleError, BrowserConsoleExt}
//! };
//!
//! let err = AppError::bad_request("invalid payload");
//!
//! #[cfg(target_arch = "wasm32")]
//! {
//! let js = err.to_js_value().expect("js value");
//! assert!(js.is_object());
//! err.log_to_browser_console().expect("console error log");
//! }
//!
//! #[cfg(not(target_arch = "wasm32"))]
//! assert!(matches!(
//! err.to_js_value(),
//! Err(BrowserConsoleError::UnsupportedTarget)
//! ));
//! # }
//! ```
pub use BrowserConsoleError;
pub use BrowserConsoleExt;