error reporting in editor window
This commit is contained in:
@ -63,6 +63,15 @@ export class UserAPI {
|
||||
//this.load = samples("github:tidalcycles/Dirt-Samples/master");
|
||||
}
|
||||
|
||||
_reportError = (error: any): void => {
|
||||
console.log(error)
|
||||
if (!this.app.show_error) {
|
||||
this.app.error_line.innerHTML = error as string;
|
||||
this.app.error_line.classList.remove('hidden');
|
||||
setInterval(() => this.app.error_line.classList.add('hidden'), 2000)
|
||||
}
|
||||
}
|
||||
|
||||
// =============================================================
|
||||
// Time functions
|
||||
// =============================================================
|
||||
|
||||
@ -18,10 +18,11 @@ const tryCatchWrapper = (
|
||||
return new Promise((resolve, _) => {
|
||||
try {
|
||||
Function(
|
||||
`"use strict";try{${codeReplace(code)}} catch (e) {console.log(e)};`
|
||||
`"use strict";try{${codeReplace(code)}} catch (e) {console.log(e); _reportError(e);};`
|
||||
).call(application.api);
|
||||
resolve(true);
|
||||
} catch (error) {
|
||||
application.error_line.innerHTML = error as string;
|
||||
console.log(error);
|
||||
resolve(false);
|
||||
}
|
||||
@ -71,6 +72,7 @@ export const tryEvaluate = async (
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
application.error_line.innerHTML = error as string;
|
||||
console.log(error);
|
||||
}
|
||||
};
|
||||
@ -87,6 +89,7 @@ export const evaluate = async (
|
||||
]);
|
||||
if (code.evaluations) code.evaluations++;
|
||||
} catch (error) {
|
||||
application.error_line.innerHTML = error as string;
|
||||
console.log(error);
|
||||
}
|
||||
};
|
||||
|
||||
@ -163,6 +163,10 @@ export class Editor {
|
||||
"vim-mode"
|
||||
) as HTMLButtonElement;
|
||||
|
||||
// Error line
|
||||
error_line: HTMLElement = document.getElementById("error_line") as HTMLElement
|
||||
show_error: boolean = false
|
||||
|
||||
constructor() {
|
||||
// ================================================================================
|
||||
// Loading the universe from local storage
|
||||
|
||||
Reference in New Issue
Block a user