Skip to content

Commit

Permalink
chore: improve debugging experience
Browse files Browse the repository at this point in the history
  • Loading branch information
SychO9 committed Dec 13, 2023
1 parent b4a82e8 commit a715b3b
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
4 changes: 3 additions & 1 deletion framework/core/js/src/common/Application.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,9 @@ export default class Application {
console.groupEnd();
}

if (e.alert) {
if (e.status === 500 && isDebug) {
app.modal.show(RequestErrorModal, { error: e, formattedError: formattedErrors });
} else if (e.alert) {
this.requestErrorAlert = this.alerts.show(e.alert, e.alert.content);
}
} else {
Expand Down
13 changes: 13 additions & 0 deletions framework/core/js/src/common/components/RequestErrorModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,19 @@ export default class RequestErrorModal<CustomAttrs extends IRequestErrorModalAtt
responseText = error.responseText;
}

if (responseText?.includes('<script> Sfdump = window.Sfdump')) {
responseText = (
<iframe
srcdoc={responseText}
className="RequestErrorModal-iframe"
onload={(e: Event) => {
const iframe = e.target as HTMLIFrameElement;
iframe.style.height = (iframe.contentWindow?.document.body.offsetHeight || 0) + 50 + 'px';
}}
/>
);
}

return (
<div className="Modal-body">
<pre>
Expand Down
6 changes: 6 additions & 0 deletions framework/core/less/common/scaffolding.less
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,12 @@ blockquote ol:last-child {
white-space: pre-wrap;
margin: 0;
}

&-iframe {
width: 100%;
max-height: 90vh;
border: 0;
}
}

#flarum-loading {
Expand Down

0 comments on commit a715b3b

Please sign in to comment.