mirror of
https://github.com/esiur/iui.git
synced 2025-05-06 06:42:58 +00:00
Debug
This commit is contained in:
parent
1294b0f413
commit
12627b1896
16
css/iui.css
16
css/iui.css
@ -3099,3 +3099,19 @@ html[dir='rtl'] .navbar-item[level='1'] {
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
.iui-error {
|
||||
background: #7171714d;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.iui-error > span {
|
||||
background: red;
|
||||
color: white;
|
||||
padding: 4px;
|
||||
}
|
@ -179,6 +179,10 @@ export class Binding {
|
||||
|
||||
if (context.error != undefined)
|
||||
{
|
||||
if (thisArg instanceof IUIElement){
|
||||
thisArg.setError(context.error);
|
||||
}
|
||||
|
||||
console.log("Execution failed", context.error.name + ": " + context.error.message, this.script, this.target);
|
||||
return;
|
||||
}
|
||||
@ -192,6 +196,11 @@ export class Binding {
|
||||
{
|
||||
return await context.value;
|
||||
} catch(ex) {
|
||||
|
||||
if (thisArg instanceof IUIElement){
|
||||
thisArg.setError(ex);
|
||||
}
|
||||
|
||||
console.log("Execution failed", ex.name + ": " + ex.message, this.script, this.target);
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,8 @@ import BindingList from "./BindingList.js";
|
||||
|
||||
export class IUI {
|
||||
|
||||
static debugMode = true;
|
||||
|
||||
static _menus = [];
|
||||
static views = [];
|
||||
static modules = {};
|
||||
|
@ -64,6 +64,22 @@ export default class IUIElement extends HTMLElement {
|
||||
}
|
||||
|
||||
|
||||
setError(exception) {
|
||||
if (!IUI.debugMode)
|
||||
return;
|
||||
|
||||
if (this._errorElement == null) {
|
||||
this._errorElement = document.createElement("div");
|
||||
this._errorElement.className = "iui-error";
|
||||
this.append(this._errorElement);
|
||||
}
|
||||
|
||||
var label = document.createElement("span");
|
||||
label.innerHTML = exception;
|
||||
this._errorElement.append(label);
|
||||
}
|
||||
|
||||
|
||||
async updated() {
|
||||
// to be implemented by the user.
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user