MCPcopy Create free account
hub / github.com/emilk/ehttp / string_from_fetch_error

Function string_from_fetch_error

ehttp/src/web.rs:37–48  ·  view source on GitHub ↗

This should only be used to handle opaque exceptions thrown by the `fetch` call.

(value: JsValue)

Source from the content-addressed store, hash-verified

35
36/// This should only be used to handle opaque exceptions thrown by the `fetch` call.
37pub(crate) fn string_from_fetch_error(value: JsValue) -> String {
38 value.as_string().unwrap_or_else(|| {
39 // TypeError means that this is an opaque `network error`, as defined by the spec:
40 // https://fetch.spec.whatwg.org/
41 if value.has_type::<js_sys::TypeError>() {
42 web_sys::console::error_1(&value);
43 "Failed to fetch, check the developer console for details".to_owned()
44 } else {
45 format!("{value:#?}")
46 }
47 })
48}
49
50pub(crate) async fn fetch_base(request: &Request) -> Result<web_sys::Response, JsValue> {
51 let opts = web_sys::RequestInit::new();

Callers 1

fetch_streamingFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected