Add error codes to our custom errors (#959)

This commit is contained in:
Fábio Rosado
2022-11-25 17:04:10 +00:00
committed by GitHub
parent 30e31a86ef
commit b062efcf17
20 changed files with 306 additions and 67 deletions

View File

@@ -11,7 +11,7 @@ import { getLogger } from './logger';
import { handleFetchError, showWarning, globalExport } from './utils';
import { calculatePaths } from './plugins/fetch';
import { createCustomElements } from './components/elements';
import { UserError, _createAlertBanner } from "./exceptions"
import { UserError, ErrorCode, _createAlertBanner } from "./exceptions"
import { type Stdio, StdioMultiplexer, DEFAULT_STDIO } from './stdio';
import { PyTerminalPlugin } from './plugins/pyterminal';
import { SplashscreenPlugin } from './plugins/splashscreen';
@@ -133,7 +133,7 @@ export class PyScriptApp {
loadRuntime() {
logger.info('Initializing runtime');
if (this.config.runtimes.length == 0) {
throw new UserError('Fatal error: config.runtimes is empty');
throw new UserError(ErrorCode.BAD_CONFIG, 'Fatal error: config.runtimes is empty');
}
if (this.config.runtimes.length > 1) {