constructor() — astro Function Reference
Architecture documentation for the constructor() function in overlay.ts from the astro codebase.
Entity Profile
Dependency Diagram
graph TD 7f32b908_586b_fc52_7198_82891a2fdf41["constructor()"] a932a37f_15f5_3203_d9bf_86f83ddbef01["ErrorOverlay"] 7f32b908_586b_fc52_7198_82891a2fdf41 -->|defined in| a932a37f_15f5_3203_d9bf_86f83ddbef01 e1a743c3_7c2e_2718_5b6c_7781a1e5f6cb["text()"] 7f32b908_586b_fc52_7198_82891a2fdf41 -->|calls| e1a743c3_7c2e_2718_5b6c_7781a1e5f6cb 18d2a16d_437c_2f03_6a56_47bf20f58c17["createLink()"] 7f32b908_586b_fc52_7198_82891a2fdf41 -->|calls| 18d2a16d_437c_2f03_6a56_47bf20f58c17 style 7f32b908_586b_fc52_7198_82891a2fdf41 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/astro/src/core/errors/overlay.ts lines 616–742
constructor(err: AstroErrorPayload['err']) {
super();
this.root = this.attachShadow({ mode: 'open' });
this.root.innerHTML = overlayTemplate;
this.dir = 'ltr';
// theme toggle logic
const themeToggle = this.root.querySelector<HTMLInputElement>('.theme-toggle-checkbox');
if (
localStorage.astroErrorOverlayTheme === 'dark' ||
(!('astroErrorOverlayTheme' in localStorage) &&
window.matchMedia('(prefers-color-scheme: dark)').matches)
) {
this?.classList.add('astro-dark');
localStorage.astroErrorOverlayTheme = 'dark';
themeToggle!.checked = true;
} else {
this?.classList.remove('astro-dark');
themeToggle!.checked = false;
}
themeToggle?.addEventListener('click', () => {
const isDark =
localStorage.astroErrorOverlayTheme === 'dark' || this?.classList.contains('astro-dark');
this?.classList.toggle('astro-dark', !isDark);
localStorage.astroErrorOverlayTheme = isDark ? 'light' : 'dark';
});
this.text('#name', err.name);
this.text('#title', err.title);
this.text('#message-content', err.message, true);
const cause = this.root.querySelector<HTMLElement>('#cause');
if (cause && err.cause) {
if (typeof err.cause === 'string') {
this.text('#cause-content', err.cause);
cause.style.display = 'block';
} else {
this.text('#cause-content', JSON.stringify(err.cause, null, 2));
cause.style.display = 'block';
}
}
const hint = this.root.querySelector<HTMLElement>('#hint');
if (hint && err.hint) {
this.text('#hint-content', err.hint, true);
hint.style.display = 'flex';
}
const docslink = this.root.querySelector<HTMLElement>('#message');
if (docslink && err.docslink) {
docslink.appendChild(this.createLink(`See Docs Reference${openNewWindowIcon}`, err.docslink));
}
const code = this.root.querySelector<HTMLElement>('#code');
if (code && err.loc?.file) {
code.style.display = 'block';
const codeHeader = code.querySelector<HTMLHeadingElement>('#code header');
const codeContent = code.querySelector<HTMLDivElement>('#code-content');
if (codeHeader) {
const separator = err.loc.file.includes('/') ? '/' : '\\';
const cleanFile = err.loc.file.split(separator).slice(-2).join('/');
const fileLocation = [cleanFile, err.loc.line, err.loc.column].filter(Boolean).join(':');
const absoluteFileLocation = [err.loc.file, err.loc.line, err.loc.column]
.filter(Boolean)
.join(':');
const codeFile = codeHeader.getElementsByTagName('h2')[0];
codeFile.textContent = fileLocation;
codeFile.title = absoluteFileLocation;
const editorLink = this.createLink(`Open in editor${openNewWindowIcon}`, undefined);
editorLink.onclick = () => {
fetch('/__open-in-editor?file=' + encodeURIComponent(absoluteFileLocation));
};
codeHeader.appendChild(editorLink);
}
if (codeContent && err.highlightedCode) {
codeContent.innerHTML = err.highlightedCode;
Domain
Subdomains
Defined In
Calls
Source
Frequently Asked Questions
What does constructor() do?
constructor() is a function in the astro codebase, defined in packages/astro/src/core/errors/overlay.ts.
Where is constructor() defined?
constructor() is defined in packages/astro/src/core/errors/overlay.ts at line 616.
What does constructor() call?
constructor() calls 2 function(s): createLink, text.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free