Skip to content

Commit

Permalink
Get a stack trace from debug panel
Browse files Browse the repository at this point in the history
  • Loading branch information
hubol committed Jan 5, 2024
1 parent 72060fe commit 4eb9764
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
3 changes: 2 additions & 1 deletion public/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,8 @@ noscript {

.debug_panel .buttons {
margin-left: 1em;
display: inline-block;
display: inline-flex;
gap: 0.8em;
visibility: hidden;
}

Expand Down
10 changes: 10 additions & 0 deletions src/lib/game-engine/debug/debug-panel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,23 @@ class DisplayObjectComponent {
constructor(readonly obj: DisplayObject) {
this._nameEl.textContent = getTypeName(obj);
this._propertiesEl.textContent = getExtendedPropertyKeysString(obj);

const toggleExpand = this.dom("button", undefined, this._buttonsEl);
toggleExpand.textContent = "Expand";
toggleExpand.onclick = () => {
this.expanded = !this.expanded;
toggleExpand.textContent = this.expanded ? "Collapse" : "Expand";
this.update();
}

if (obj['Throwable']) {
const getStack = this.dom("button", undefined, this._buttonsEl);
getStack.textContent = "Stack";
getStack.onclick = () => {
throw obj['Throwable'];
}
}

this.update();
}

Expand Down
1 change: 1 addition & 0 deletions src/lib/pixi/dev-assign-displayobject-identifiers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export function devAssignDisplayObjectIdentifiers(constructed: DisplayObject) {
const [ name, stack ] = getDisplayObjectStack(error);
constructed['Name'] = name;
constructed['Stack'] = stack;
constructed['Throwable'] = error;
}

const regex = new RegExp(/(?:Error)?\s+at\s(?:Object\.)?((?:new\s)?[a-zA-Z0-9_\.]*)\s\(.*\)/gm);
Expand Down

0 comments on commit 4eb9764

Please sign in to comment.