File tree Expand file tree Collapse file tree 2 files changed +14
-9
lines changed
Expand file tree Collapse file tree 2 files changed +14
-9
lines changed Original file line number Diff line number Diff line change @@ -187,9 +187,9 @@ export const page_init = () => {
187187 on_navigate ,
188188 ) ;
189189 document . addEventListener ( "click" , on_click ) ;
190- // Provide basic error reporting for uncaught errors. However, enabling either of these makes the Client not work. ???
191- // window.addEventListener("unhandledrejection", on_error);
192- // window.addEventListener("error", on_error);
190+ // Provide basic error reporting for uncaught errors.
191+ window . addEventListener ( "unhandledrejection" , on_error ) ;
192+ window . addEventListener ( "error" , on_error ) ;
193193
194194 window . CodeChatEditor = {
195195 open_lp,
@@ -583,6 +583,7 @@ export const on_error = (event: Event) => {
583583 err_str = `Unexpected error ${ typeof event } : ${ event } ` ;
584584 }
585585 show_toast ( `Error: ${ err_str } ` ) ;
586+ console . error ( event ) ;
586587} ;
587588
588589// Testing
Original file line number Diff line number Diff line change @@ -104,20 +104,21 @@ class WebSocketComm {
104104 } ;
105105
106106 // Provide logging to help track down errors.
107- this . ws . onerror = ( event : any ) => {
107+ this . ws . onerror = ( event : Event ) => {
108108 report_error (
109- `CodeChat Client: websocket error ${ JSON . stringify ( event ) } .` ,
109+ `CodeChat Client: websocket error.` , event
110110 ) ;
111111 } ;
112112
113- this . ws . onclose = ( event : any ) => {
113+ this . ws . onclose = ( event : CloseEvent ) => {
114114 console_log (
115- `CodeChat Client: websocket closed by event type ${ event . type } : ${ event . detail } . This should only happen on shutdown.` ,
115+ `CodeChat Client: websocket ${ event . wasClean ? "" : "*NOT*" } cleanly closed ${ event . reason } . This should only happen on shutdown.`
116116 ) ;
117+ console_log ( event ) ;
117118 } ;
118119
119120 // Handle websocket messages.
120- this . ws . onmessage = ( event : any ) => {
121+ this . ws . onmessage = ( event : MessageEvent ) => {
121122 // Parse the received message, which must be a single element of a
122123 // dictionary representing a `JointMessage`.
123124 const joint_message = JSON . parse ( event . data ) as EditorMessage ;
@@ -444,7 +445,10 @@ export const format_struct = (complex_data_structure: any): string =>
444445 )
445446 : "" ;
446447
447- const report_error = ( text : string ) => {
448+ const report_error = ( text : string , ... objs : any ) => {
448449 console . error ( text ) ;
450+ if ( objs !== undefined ) {
451+ console . log ( ...objs ) ;
452+ }
449453 show_toast ( text ) ;
450454} ;
You can’t perform that action at this time.
0 commit comments