@@ -22,14 +22,15 @@ Stable categories, conservative HTTP mapping, no `unsafe`.
2222
2323~~~ toml
2424[dependencies ]
25- masterror = { version = " 0.3 " , default-features = false }
25+ masterror = { version = " 0.4 " , default-features = false }
2626# or with features:
27- # masterror = { version = "0.3 ", features = [
27+ # masterror = { version = "0.4 ", features = [
2828# "axum", "actix", "serde_json", "openapi",
2929# "sqlx", "reqwest", "redis", "validator", "config", "tokio", "teloxide"
3030# ] }
3131~~~
3232
33+ * Since v0.4.0: optional ` frontend ` feature for WASM/browser console logging.*
3334* Since v0.3.0: stable ` AppCode ` enum and extended ` ErrorResponse ` with retry/authentication metadata.*
3435
3536---
@@ -53,10 +54,10 @@ masterror = { version = "0.3", default-features = false }
5354~~~ toml
5455[dependencies ]
5556# lean core
56- masterror = { version = " 0.3 " , default-features = false }
57+ masterror = { version = " 0.4 " , default-features = false }
5758
5859# with Axum/Actix + JSON + integrations
59- # masterror = { version = "0.3 ", features = [
60+ # masterror = { version = "0.4 ", features = [
6061# "axum", "actix", "serde_json", "openapi",
6162# "sqlx", "reqwest", "redis", "validator", "config", "tokio", "teloxide"
6263# ] }
@@ -160,12 +161,37 @@ async fn payload() -> impl Responder {
160161
161162~~~ toml
162163[dependencies ]
163- masterror = { version = " 0.3 " , features = [" openapi" , " serde_json" ] }
164+ masterror = { version = " 0.4 " , features = [" openapi" , " serde_json" ] }
164165utoipa = " 5"
165166~~~
166167
167168</details >
168169
170+ <details >
171+ <summary ><b >Browser (WASM)</b ></summary >
172+
173+ ~~~ rust
174+ // features = ["frontend"]
175+ use masterror :: {AppError , AppErrorKind };
176+ use masterror :: frontend :: {BrowserConsoleError , BrowserConsoleExt };
177+
178+ fn report () -> Result <(), BrowserConsoleError > {
179+ let err = AppError :: bad_request (" missing field" );
180+ let payload = err . to_js_value ()? ;
181+ assert! (payload . is_object ());
182+
183+ #[cfg(target_arch = " wasm32" )]
184+ err . log_to_browser_console ()? ;
185+
186+ Ok (())
187+ }
188+ ~~~
189+
190+ - On non-WASM targets ` log_to_browser_console ` returns
191+ ` BrowserConsoleError::UnsupportedTarget ` .
192+
193+ </details >
194+
169195<details >
170196 <summary ><b >Feature flags</b ></summary >
171197
@@ -174,6 +200,7 @@ utoipa = "5"
174200- ` openapi ` — utoipa schema
175201- ` serde_json ` — JSON details
176202- ` sqlx ` , ` redis ` , ` reqwest ` , ` validator ` , ` config ` , ` tokio ` , ` multipart ` , ` teloxide ` , ` telegram-webapp-sdk `
203+ - ` frontend ` — convert errors into ` JsValue ` and log via ` console.error ` (WASM)
177204- ` turnkey ` — domain taxonomy and conversions for Turnkey errors
178205
179206</details >
@@ -201,13 +228,13 @@ utoipa = "5"
201228Minimal core:
202229
203230~~~ toml
204- masterror = { version = " 0.3 " , default-features = false }
231+ masterror = { version = " 0.4 " , default-features = false }
205232~~~
206233
207234API (Axum + JSON + deps):
208235
209236~~~ toml
210- masterror = { version = " 0.3 " , features = [
237+ masterror = { version = " 0.4 " , features = [
211238 " axum" , " serde_json" , " openapi" ,
212239 " sqlx" , " reqwest" , " redis" , " validator" , " config" , " tokio"
213240] }
@@ -216,7 +243,7 @@ masterror = { version = "0.3", features = [
216243API (Actix + JSON + deps):
217244
218245~~~ toml
219- masterror = { version = " 0.3 " , features = [
246+ masterror = { version = " 0.4 " , features = [
220247 " actix" , " serde_json" , " openapi" ,
221248 " sqlx" , " reqwest" , " redis" , " validator" , " config" , " tokio"
222249] }
0 commit comments