Skip to content

Commit

Permalink
center error
Browse files Browse the repository at this point in the history
  • Loading branch information
greggman committed Dec 24, 2024
1 parent 64c7a8f commit 8d06f58
Showing 1 changed file with 30 additions and 7 deletions.
37 changes: 30 additions & 7 deletions lib/servez.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,37 @@ const noopLogger = {
}),
};

function makeErrorHTML(msg) {
return `
<style>
:root {
color-scheme: light dark;
function escapeStringForHTML(s) {
return s
.replaceAll('&', '&amp;')
.replaceAll('<', '&lt;')
.replaceAll('>', '&gt;');
}
</style>
<pre>${msg}</pre>`;

function makeErrorHTML(msg) {
return `\
<!DOCTYPE html>
<html>
<style>
:root {
color-scheme: light dark;
}
html, body, .msg {
height: 100%;
font-family: monospace;
}
.msg {
word-break: break-word;
display: flex;
justify-content: center;
align-items: center;
}
</style>
<body>
<div class="msg"><div>${escapeStringForHTML(msg)}</div></div>
</body>
</html>
`;
}

class Servez extends EventEmitter {
Expand Down

0 comments on commit 8d06f58

Please sign in to comment.