Event to detect crash in Cesium viewer and refresh the viewer

Hi,

I have created an application using Cesium. It works well. But sometimes, it crashes.
Is there any event or way to detect crashes in Cesium Viewer so I can refresh the application while crashing it?

I appreciate any help you can provide.