@@ -26,9 +26,9 @@ use wasm_bindgen::prelude::*;
26
26
use wasm_bindgen_derive:: TryFromJsValue ;
27
27
use wasm_bindgen_futures:: { JsFuture , future_to_promise} ;
28
28
29
- use crate :: TableDataExt ;
30
29
pub use crate :: table:: * ;
31
30
use crate :: utils:: { ApiError , ApiResult , JsValueSerdeExt , LocalPollLoop } ;
31
+ use crate :: { TableDataExt , apierror} ;
32
32
33
33
#[ wasm_bindgen]
34
34
extern "C" {
@@ -72,7 +72,6 @@ impl ProxySession {
72
72
Ok ( ( ) )
73
73
}
74
74
75
-
76
75
pub async fn close ( self ) {
77
76
self . 0 . close ( ) . await ;
78
77
}
@@ -221,14 +220,10 @@ impl Client {
221
220
222
221
#[ doc( hidden) ]
223
222
#[ 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 < ( ) > {
229
224
self . client
230
225
. handle_error (
231
- error,
226
+ ClientError :: Unknown ( error) ,
232
227
reconnect. map ( |reconnect| {
233
228
let reconnect =
234
229
JsReconnect :: from ( move |( ) | match reconnect. call0 ( & JsValue :: UNDEFINED ) {
@@ -262,7 +257,7 @@ impl Client {
262
257
#[ wasm_bindgen]
263
258
pub async fn on_error ( & self , callback : Function ) -> ApiResult < u32 > {
264
259
let callback = JsReconnect :: from (
265
- move |( message, reconnect) : ( Option < String > , Option < ReconnectCallback > ) | {
260
+ move |( message, reconnect) : ( ClientError , Option < ReconnectCallback > ) | {
266
261
let cl: Closure < dyn Fn ( ) -> js_sys:: Promise > = Closure :: new ( move || {
267
262
let reconnect = reconnect. clone ( ) ;
268
263
future_to_promise ( async move {
@@ -276,7 +271,7 @@ impl Client {
276
271
277
272
if let Err ( e) = callback. call2 (
278
273
& JsValue :: UNDEFINED ,
279
- & JsValue :: from ( message) ,
274
+ & JsValue :: from ( apierror ! ( ClientError ( message) ) ) ,
280
275
& cl. into_js_value ( ) ,
281
276
) {
282
277
tracing:: warn!( "{:?}" , e) ;
0 commit comments