@@ -54,28 +54,35 @@ int main(int argc, char* args[]) {
5454 return EXIT_FAILURE;
5555 }
5656
57+
5758 try {
5859 // Try to perform error recovery from the snapshot if necessary and possible.
5960 if (wm->snapshot ().FileExists ()) {
6061 wm->snapshot ().Load ();
6162 }
63+ wm->Run (); // enter main event loop
64+
65+ } catch (const std::bad_alloc& ex) {
66+ fputs (" Out of memory\n " , stderr);
67+ return EXIT_FAILURE;
6268
63- // Run the window manager.
64- wm->Run ();
6569 } catch (const wmderland::Snapshot::SnapshotLoadError& ex) {
6670 // If we cannot recover from errors using the snapshot,
6771 // then return with EXIT_FAILURE.
6872 WM_LOG (ERROR, ex.what ());
73+ std::cerr << ex.what () << std::endl;
6974 rename (wm->snapshot ().filename ().c_str (), (wm->snapshot ().filename () + " .failed_to_load" ).c_str ());
7075 return EXIT_FAILURE;
76+
7177 } catch (const std::exception& ex) {
72- // Try to exec itself and recover from errors the snapshot.
78+ // Try to exec itself and recover from errors using the snapshot.
7379 // If snapshot fails to load, it will throw an SnapshotLoadError.
7480 // See the previous catch block.
7581 WM_LOG (ERROR, ex.what ());
7682 wmderland::sys_utils::NotifySend (" An error occurred. Recovering..." , NOTIFY_SEND_CRITICAL);
7783 wm->snapshot ().Save ();
7884 execl (args[0 ], args[0 ], nullptr );
85+
7986 } catch (...) {
8087 WM_LOG (ERROR, " Unknown exception caught!" );
8188 return EXIT_FAILURE;
0 commit comments