You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: packages/astro/src/core/errors/README.md
+22-6
Original file line number
Diff line number
Diff line change
@@ -21,8 +21,8 @@ Message:
21
21
22
22
- Begin with **what happened** and **why**. (ex: `Could not use {feature} because Server-side Rendering is not enabled.`)
23
23
- Then, **describe the action the user should take**. (ex: `Update your Astro config with `output: 'server'` to enable Server-side Rendering.`)
24
-
- Although this does not need to be as brief as the `title`, try to keep sentences short, clear and direct to give the reader all the necessary information quickly as possible.
25
-
-Instead of writing a longer message, consider using a `hint`.
24
+
- Although this does not need to be as brief as the `title`, try to keep sentences short, clear and direct to give the reader all the necessary information quickly as possible. Users should be able to skim the message and understand the problem and solution.
25
+
-If your message is too long, or the solution is not guaranteed to work, use the `hint` property to provide more information.
26
26
27
27
Hint:
28
28
@@ -44,10 +44,10 @@ If you are unsure about anything, ask [Erika](https://github.com/Princesseuh)!
44
44
45
45
### Shape
46
46
47
-
-**Names are permanent**, and should never be changed, nor deleted. Users should always be able to find an error by searching, and this ensures a matching result. When an error is no longer relevant, it should be deprecated, not removed.
47
+
-**Names are permanent**, and should never be changed. Users should always be able to find an error by searching, and this ensures a matching result.
48
48
- Contextual information may be used to enhance the message or the hint. However, the code that caused the error or the position of the error should not be included in the message as they will already be shown as part of the error.
49
49
- Do not prefix `title`, `message` and `hint` with descriptive words such as "Error:" or "Hint:" as it may lead to duplicated labels in the UI / CLI.
50
-
- Dynamic error messages must use the following shape:
50
+
- Dynamic error messages **must** use the following shape:
51
51
52
52
```js
53
53
message: (arguments) =>`text ${substitute}`;
@@ -69,8 +69,9 @@ Here's how to create and format the comments:
69
69
/**
70
70
* @docs <- Needed for the comment to be used for docs
71
71
* @message <- (Optional) Clearer error message to show in cases where the original one is too complex (ex: because of conditional messages)
72
-
* @see<- List of additional references users can look at
72
+
* @see<-(Optional) List of additional references users can look at
73
73
* @description <- Description of the error
74
+
* @deprecated <- (Optional) If the error is no longer relevant, when it was removed and why (see "Removing errors" section below)
74
75
*/
75
76
```
76
77
@@ -89,6 +90,19 @@ Example:
89
90
90
91
The `@message` property is intended to provide slightly more context when it is helpful: a more descriptive error message or a collection of common messages if there are multiple possible error messages. Try to avoid making substantial changes to existing messages so that they are easy to find for users who copy and search the exact content of an error message.
91
92
93
+
### Removing errors
94
+
95
+
If the error cannot be triggered at all anymore, it can deprecated by adding a `@deprecated` tag to the JSDoc comment with a message that will be shown in the docs. This message is useful for users on previous versions who might still encounter the error so that they can know that upgrading to a newer version of Astro would perhaps solve their issue.
96
+
97
+
```js
98
+
/**
99
+
* @docs
100
+
* @deprecated Removed in Astro v9.8.6 as it is no longer relevant due to...
101
+
*/
102
+
```
103
+
104
+
Alternatively, if no special deprecation message is needed, errors can be directly removed from the `errors-data.ts` file. A basic message will be shown in the docs stating that the error can no longer appear in the latest version of Astro.
105
+
92
106
### Always remember
93
107
94
108
Error are a reactive strategy. They are the last line of defense against a mistake.
@@ -99,5 +113,7 @@ While adding a new error message, ask yourself, "Was there a way this situation
99
113
100
114
## Additional resources on writing good error messages
101
115
116
+
-[Compiler errors for humans](https://elm-lang.org/news/compiler-errors-for-humans)
102
117
-[When life gives you lemons, write better error messages](https://wix-ux.com/when-life-gives-you-lemons-write-better-error-messages-46c5223e1a2f)
103
-
-[RustConf 2020 - Bending the Curve: A Personal Tutor at Your Fingertips by Esteban Kuber](https://www.youtube.com/watch?v=Z6X7Ada0ugE) (part on error messages starts around 19:17)
118
+
-[RustConf 2020 - Bending the Curve: A Personal Tutor at Your Fingertips by Esteban Kuber](https://www.youtube.com/watch?v=Z6X7Ada0ugE)
119
+
-[What's in a good error](https://erika.florist/articles/gooderrors) (by the person who wrote this document!)
* The `Astro.redirect` function is only available when [Server-side rendering](/en/guides/server-side-rendering/) is enabled.
44
-
*
45
-
* To redirect on a static website, the [meta refresh attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/meta) can be used. Certain hosts also provide config-based redirects (ex: [Netlify redirects](https://docs.netlify.com/routing/redirects/)).
46
-
* @deprecated Deprecated since version 2.6.
47
-
*/
48
-
exportconstStaticRedirectNotAvailable={
49
-
name: 'StaticRedirectNotAvailable',
50
-
title: '`Astro.redirect` is not available in static mode.',
51
-
message:
52
-
"Redirects are only available when using `output: 'server'` or `output: 'hybrid'`. Update your Astro config if you need SSR features.",
53
-
hint: 'See https://docs.astro.build/en/guides/server-side-rendering/ for more information on how to enable SSR.',
* `getStaticPaths` no longer expose an helper for generating a RSS feed. We recommend migrating to the [@astrojs/rss](https://docs.astro.build/en/guides/rss/#setting-up-astrojsrss)integration instead.
312
-
*/
313
-
exportconstGetStaticPathsRemovedRSSHelper={
314
-
name: 'GetStaticPathsRemovedRSSHelper',
315
-
title: 'getStaticPaths RSS helper is not available anymore.',
316
-
message:
317
-
'The RSS helper has been removed from `getStaticPaths`. Try the new @astrojs/rss package instead.',
318
-
hint: 'See https://docs.astro.build/en/guides/rss/ for more information.',
* Astro could not find an image you included in your Markdown content. Usually, this is simply caused by a typo in the path.
744
-
*
745
-
* Images in Markdown are relative to the current file. To refer to an image that is located in the same folder as the `.md` file, the path should start with `./`
0 commit comments