[Bootstrap] Deep integrate ErrorHandler, also fix uncaught in Splash ThemeSync
This commit is contained in:
		
							parent
							
								
									f7ccaa8808
								
							
						
					
					
						commit
						f40682c8a9
					
				
					 3 changed files with 16 additions and 30 deletions
				
			
		
							
								
								
									
										17
									
								
								src/bootstrap.js
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										17
									
								
								src/bootstrap.js
									
										
									
									
										vendored
									
									
								
							|  | @ -1,4 +1,4 @@ | |||
| const { app } = require('electron'); | ||||
| const { app, dialog } = require('electron'); | ||||
| const { readFileSync } = require('fs'); | ||||
| const { join } = require('path'); | ||||
| 
 | ||||
|  | @ -14,8 +14,17 @@ global.releaseChannel = buildInfo.releaseChannel; | |||
| 
 | ||||
| log('BuildInfo', buildInfo); | ||||
| 
 | ||||
| const { fatal, handled, init: EHInit } = require('./errorHandler'); | ||||
| EHInit(); | ||||
| const fatal = e => { | ||||
|   log('Fatal', e); | ||||
| 
 | ||||
|   dialog.showMessageBox({ | ||||
|     type: 'error', | ||||
|     message: 'A fatal Javascript error occured', | ||||
|     detail: e?.stack ?? String(e) | ||||
|   }).then(() => app.quit()); | ||||
| }; | ||||
| // process.on('uncaughtException', fatal);
 | ||||
| 
 | ||||
| 
 | ||||
| const splash = require('./splash'); | ||||
| 
 | ||||
|  | @ -69,7 +78,7 @@ const startUpdate = async () => { | |||
|     inst.on('host-updated', () => autoStart.update(() => {})); | ||||
|     inst.on('unhandled-exception', fatal); | ||||
|     inst.on('InconsistentInstallerState', fatal); | ||||
|     inst.on('update-error', handled); | ||||
|     inst.on('update-error', console.error); | ||||
| 
 | ||||
|     require('./firstRun').do(inst); | ||||
|   } else { | ||||
|  |  | |||
|  | @ -1,25 +0,0 @@ | |||
| const { app, dialog } = require("electron"); | ||||
| 
 | ||||
| exports.init = () => { | ||||
|   process.on('uncaughtException', err => { | ||||
|     const stack = err.stack ?? String(err); | ||||
|     console.warn(stack); | ||||
| 
 | ||||
|     // dialog.showErrorBox('A JavaScript error occurred in the main process', message);
 | ||||
|   }); | ||||
| }; | ||||
| 
 | ||||
| 
 | ||||
| exports.fatal = (err) => { | ||||
|   log('ErrorHandler', 'Fatal:', err); | ||||
| 
 | ||||
|   dialog.showMessageBox(null, { | ||||
|     type: 'error', | ||||
|     message: 'A fatal Javascript error occured', | ||||
|     detail: err?.stack ?? String(err) | ||||
|   }).then(() => app.quit()); | ||||
| }; | ||||
| 
 | ||||
| exports.handled = (err) => { | ||||
|   log('ErrorHandler', 'Handled:', err); | ||||
| }; | ||||
|  | @ -85,7 +85,9 @@ const launchSplash = (startMin) => { | |||
|   if (process.platform !== 'darwin') win.on('closed', () => !launchedMainWindow && app.quit()); | ||||
| 
 | ||||
|   wc.once('dom-ready', () => { | ||||
|     if (oaConfig.themeSync !== false) wc.insertCSS(JSON.parse(fs.readFileSync(join(paths.getUserData(), 'userDataCache.json'), 'utf8')).openasarSplashCSS); | ||||
|     if (oaConfig.themeSync !== false) try { | ||||
|       wc.insertCSS(JSON.parse(fs.readFileSync(join(paths.getUserData(), 'userDataCache.json'), 'utf8')).openasarSplashCSS); | ||||
|     } catch { } | ||||
| 
 | ||||
|     if (oaConfig.splashText === true) { | ||||
|       const buildInfo = require('../utils/buildInfo.js'); | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue