@@ -26,9 +26,9 @@ use wasm_bindgen::prelude::*;
2626use wasm_bindgen_derive:: TryFromJsValue ;
2727use wasm_bindgen_futures:: { JsFuture , future_to_promise} ;
2828
29- use crate :: TableDataExt ;
3029pub use crate :: table:: * ;
3130use crate :: utils:: { ApiError , ApiResult , JsValueSerdeExt , LocalPollLoop } ;
31+ use crate :: { TableDataExt , apierror} ;
3232
3333#[ wasm_bindgen]
3434extern "C" {
@@ -72,7 +72,6 @@ impl ProxySession {
7272 Ok ( ( ) )
7373 }
7474
75-
7675 pub async fn close ( self ) {
7776 self . 0 . close ( ) . await ;
7877 }
@@ -221,14 +220,10 @@ impl Client {
221220
222221 #[ doc( hidden) ]
223222 #[ wasm_bindgen]
224- pub async fn handle_error (
225- & self ,
226- error : Option < String > ,
227- reconnect : Option < Function > ,
228- ) -> ApiResult < ( ) > {
223+ pub async fn handle_error ( & self , error : String , reconnect : Option < Function > ) -> ApiResult < ( ) > {
229224 self . client
230225 . handle_error (
231- error,
226+ ClientError :: Unknown ( error) ,
232227 reconnect. map ( |reconnect| {
233228 let reconnect =
234229 JsReconnect :: from ( move |( ) | match reconnect. call0 ( & JsValue :: UNDEFINED ) {
@@ -262,7 +257,7 @@ impl Client {
262257 #[ wasm_bindgen]
263258 pub async fn on_error ( & self , callback : Function ) -> ApiResult < u32 > {
264259 let callback = JsReconnect :: from (
265- move |( message, reconnect) : ( Option < String > , Option < ReconnectCallback > ) | {
260+ move |( message, reconnect) : ( ClientError , Option < ReconnectCallback > ) | {
266261 let cl: Closure < dyn Fn ( ) -> js_sys:: Promise > = Closure :: new ( move || {
267262 let reconnect = reconnect. clone ( ) ;
268263 future_to_promise ( async move {
@@ -276,7 +271,7 @@ impl Client {
276271
277272 if let Err ( e) = callback. call2 (
278273 & JsValue :: UNDEFINED ,
279- & JsValue :: from ( message) ,
274+ & JsValue :: from ( apierror ! ( ClientError ( message) ) ) ,
280275 & cl. into_js_value ( ) ,
281276 ) {
282277 tracing:: warn!( "{:?}" , e) ;
0 commit comments