Skip to content

Commit

Permalink
Merge branch 'withastro:main' into fix-lit-hydration
Browse files Browse the repository at this point in the history
  • Loading branch information
e111077 committed Jan 31, 2023
2 parents 59f0682 + 474ecc7 commit b760e74
Show file tree
Hide file tree
Showing 7 changed files with 70 additions and 265 deletions.
5 changes: 5 additions & 0 deletions .changeset/clever-panthers-end.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'astro': patch
---

Error overlay will now show the error's `cause` if available.
5 changes: 5 additions & 0 deletions .changeset/cuddly-donkeys-warn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@astrojs/mdx': patch
---

Update MDX README
2 changes: 2 additions & 0 deletions packages/astro/src/core/errors/dev/vite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ export interface AstroErrorPayload {
line?: number;
column?: number;
};
cause?: unknown;
};
}

Expand Down Expand Up @@ -174,6 +175,7 @@ export async function getViteErrorPayload(err: ErrorWithMetadata): Promise<Astro
},
plugin,
stack: err.stack,
cause: err.cause,
},
};

Expand Down
2 changes: 1 addition & 1 deletion packages/astro/src/core/errors/errors-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ See https://docs.astro.build/en/guides/server-side-rendering/ for more informati
* @docs
* @message
* **Example error messages:**<br/>
* InvalidComponentArgs: Invalid arguments passed to <MyAstroComponent> component.
* InvalidComponentArgs: Invalid arguments passed to `<MyAstroComponent>` component.
* @description
* Astro components cannot be rendered manually via a function call, such as `Component()` or `{items.map(Component)}`. Prefer the component syntax `<Component />` or `{items.map(item => <Component {...item} />)}`.
*/
Expand Down
29 changes: 26 additions & 3 deletions packages/astro/src/core/errors/overlay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,8 @@ const style = /* css */ `
#message-hints,
#stack,
#code {
#code,
#cause {
border-radius: var(--roundiness);
background-color: var(--box-background);
}
Expand Down Expand Up @@ -471,7 +472,8 @@ const style = /* css */ `
color: var(--error-text);
}
#stack h2 {
#stack h2,
#cause h2 {
color: var(--title-text);
font-family: var(--font-normal);
font-size: 22px;
Expand All @@ -480,14 +482,19 @@ const style = /* css */ `
border-bottom: 1px solid var(--border);
}
#stack-content {
#stack-content,
#cause-content {
font-size: 14px;
white-space: pre;
line-height: 21px;
overflow: auto;
padding: 24px;
color: var(--stack-text);
}
#cause {
display: none;
}
`;

const overlayTemplate = /* html */ `
Expand Down Expand Up @@ -552,6 +559,11 @@ ${style.trim()}
<h2>Stack Trace</h2>
<div id="stack-content"></div>
</section>
<section id="cause">
<h2>Cause</h2>
<div id="cause-content"></div>
</section>
</div>
</div>
`;
Expand Down Expand Up @@ -593,6 +605,17 @@ class ErrorOverlay extends HTMLElement {
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);
Expand Down
5 changes: 4 additions & 1 deletion packages/integrations/image/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,10 @@ This can be helpful if you need to add preload links to a page's `<head>`.
---
import { getImage } from '@astrojs/image';
const { src } = await getImage({src: '../assets/hero.png'});
const { src } = await getImage({
src: import('../assets/hero.png'),
alt: "My hero image"
});
---
<html>
Expand Down

0 comments on commit b760e74

Please sign in to comment.