Skip to content

Commit

Permalink
Remove error codes (withastro#3463)
Browse files Browse the repository at this point in the history
Co-authored-by: Chris Swithinbank <[email protected]>
  • Loading branch information
Princesseuh and delucis authored Jun 22, 2023
1 parent c322135 commit 82dff82
Show file tree
Hide file tree
Showing 184 changed files with 590 additions and 706 deletions.
12 changes: 3 additions & 9 deletions scripts/error-docgen.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,13 @@ export async function run() {
const errorTitle = sanitizeString(
astroErrorData.errors[comment.meta.code.name].title ?? comment.name
);
const errorCode = astroErrorData.errors[comment.name].code;
const completeReferenceEntry = [
// Errors can be deprecated, as such we add a little "deprecated" caution to errors that needs it
getDeprecatedText(comment.deprecated),
``,
// Get the error message and print it in a blockquote
getMessage(
comment.name,
errorCode,
astroErrorData.errors[comment.name].message,
comment.tags.find((tag) => tag.title === 'message')?.value
),
Expand All @@ -90,9 +88,7 @@ export async function run() {

// Build string for error reference list
astroResult += [
`- [**${comment.name}**](/en/reference/errors/${fileName}/) (E${padCode(
errorCode
)})<br/>${errorTitle}\n`,
`- [**${comment.name}**](/en/reference/errors/${fileName}/)<br/>${errorTitle}\n`,
]
.filter((l) => l !== undefined)
.join('\n');
Expand All @@ -106,12 +102,11 @@ export async function run() {

/**
* @param {string} errorName
* @param {number} errorCode
* @param {string} message
* @param {string} cleanMessage
* @returns {(string | undefined)} Formatted message for the error or `undefined`
*/
function getMessage(errorName, errorCode, message, cleanMessage) {
function getMessage(errorName, message, cleanMessage) {
let resultMessage = undefined;

if (cleanMessage) {
Expand All @@ -127,8 +122,7 @@ export async function run() {
}

if (resultMessage) {
resultMessage += ` (E${padCode(errorCode)})\n`;
return resultMessage;
return resultMessage + '\n';
}

return undefined;
Expand Down
126 changes: 64 additions & 62 deletions src/content/docs/en/reference/error-reference.mdx

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import DontEditWarning from '~/components/DontEditWarning.astro'
<DontEditWarning />


> **AstroGlobNoMatch**: `Astro.glob(GLOB_STR)` did not return any matching files. Check the pattern for typos. (E03036)
> **AstroGlobNoMatch**: `Astro.glob(GLOB_STR)` did not return any matching files. Check the pattern for typos.
## What went wrong?
`Astro.glob()` did not return any matching files. There might be a typo in the glob pattern.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import DontEditWarning from '~/components/DontEditWarning.astro'
<DontEditWarning />


> **AstroGlobUsedOutside**: `Astro.glob(GLOB_STR)` can only be used in `.astro` files. `import.meta.glob(GLOB_STR)` can be used instead to achieve a similar result. (E03035)
> **AstroGlobUsedOutside**: `Astro.glob(GLOB_STR)` can only be used in `.astro` files. `import.meta.glob(GLOB_STR)` can be used instead to achieve a similar result.
## What went wrong?
`Astro.glob()` can only be used in `.astro` files. You can use [`import.meta.glob()`](https://vitejs.dev/guide/features.html#glob-import) instead to acheive the same result.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import DontEditWarning from '~/components/DontEditWarning.astro'
<DontEditWarning />


> **ClientAddressNotAvailable**: `Astro.clientAddress` is not available in the `ADAPTER_NAME` adapter. File an issue with the adapter to add support. (E03002)
> **ClientAddressNotAvailable**: `Astro.clientAddress` is not available in the `ADAPTER_NAME` adapter. File an issue with the adapter to add support.
## What went wrong?
The adapter you're using unfortunately does not support `Astro.clientAddress`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import DontEditWarning from '~/components/DontEditWarning.astro'
<DontEditWarning />


> A collection queried via `getCollection()` does not exist. (E09004)
> A collection queried via `getCollection()` does not exist.
## What went wrong?
When querying a collection, ensure a collection directory with the requested name exists under `src/content/`.
Expand Down
2 changes: 1 addition & 1 deletion src/content/docs/en/reference/errors/config-legacy-key.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import DontEditWarning from '~/components/DontEditWarning.astro'
<DontEditWarning />


> **ConfigLegacyKey**: Legacy configuration detected: `LEGACY_CONFIG_KEY`. (E07002)
> **ConfigLegacyKey**: Legacy configuration detected: `LEGACY_CONFIG_KEY`.
## What went wrong?
Astro detected a legacy configuration option in your configuration file.
Expand Down
2 changes: 1 addition & 1 deletion src/content/docs/en/reference/errors/config-not-found.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import DontEditWarning from '~/components/DontEditWarning.astro'
<DontEditWarning />


> **ConfigNotFound**: Unable to resolve `--config "CONFIG_FILE"`. Does the file exist? (E07001)
> **ConfigNotFound**: Unable to resolve `--config "CONFIG_FILE"`. Does the file exist?
## What went wrong?
The specified configuration file using `--config` could not be found. Make sure that it exists or that the path is correct
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import DontEditWarning from '~/components/DontEditWarning.astro'
<DontEditWarning />


> `COLLECTION_NAME` contains entries of type `ACTUAL_TYPE`, but is configured as a `EXPECTED_TYPE` collection. (E09006)
> `COLLECTION_NAME` contains entries of type `ACTUAL_TYPE`, but is configured as a `EXPECTED_TYPE` collection.
## What went wrong?
Content collections must contain entries of the type configured. Collections are `type: 'content'` by default. Try adding `type: 'data'` to your collection config for data collections.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import DontEditWarning from '~/components/DontEditWarning.astro'
<DontEditWarning />


> **ContentSchemaContainsSlugError**: A content collection schema should not contain `slug` since it is reserved for slug generation. Remove this from your COLLECTION_NAME collection schema. (E09003)
> **ContentSchemaContainsSlugError**: A content collection schema should not contain `slug` since it is reserved for slug generation. Remove this from your COLLECTION_NAME collection schema.
## What went wrong?
A content collection schema should not contain the `slug` field. This is reserved by Astro for generating entry slugs. Remove `slug` from your schema. You can still use custom slugs in your frontmatter.
Expand Down
2 changes: 1 addition & 1 deletion src/content/docs/en/reference/errors/csssyntax-error.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import DontEditWarning from '~/components/DontEditWarning.astro'

> **Example error messages:**<br/>
CSSSyntaxError: Missed semicolon<br/>
CSSSyntaxError: Unclosed string<br/> (E05001)
CSSSyntaxError: Unclosed string<br/>
## What went wrong?
Astro encountered an error while parsing your CSS, due to a syntax error. This is often caused by a missing semicolon.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import DontEditWarning from '~/components/DontEditWarning.astro'
<DontEditWarning />


> `COLLECTION_ENTRY_NAME` failed to parse. (E09007)
> `COLLECTION_ENTRY_NAME` failed to parse.
## What went wrong?
Collection entries of `type: 'data'` must return an object with valid JSON (for `.json` entries) or YAML (for `.yaml` entries).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import DontEditWarning from '~/components/DontEditWarning.astro'
<DontEditWarning />


> `COLLECTION_NAME` contains multiple entries with the same slug: `SLUG`. Slugs must be unique. (E09008)
> `COLLECTION_NAME` contains multiple entries with the same slug: `SLUG`. Slugs must be unique.
## What went wrong?
Content collection entries must have unique slugs. Duplicates are often caused by the `slug` frontmatter property.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import DontEditWarning from '~/components/DontEditWarning.astro'
<DontEditWarning />


> **ExpectedImageOptions**: Expected getImage() parameter to be an object. Received `OPTIONS`. (E03028)
> **ExpectedImageOptions**: Expected getImage() parameter to be an object. Received `OPTIONS`.
## What went wrong?
`getImage()`'s first parameter should be an object with the different properties to apply to your image.
Expand Down
2 changes: 1 addition & 1 deletion src/content/docs/en/reference/errors/expected-image.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import DontEditWarning from '~/components/DontEditWarning.astro'
<DontEditWarning />


> **ExpectedImage**: Expected `src` property to be either an ESM imported image or a string with the path of a remote image. Received `OPTIONS`. (E03027)
> **ExpectedImage**: Expected `src` property to be either an ESM imported image or a string with the path of a remote image. Received `OPTIONS`.
## What went wrong?
An image's `src` property is not valid. The Image component requires the `src` attribute to be either an image that has been ESM imported or a string. This is also true for the first parameter of `getImage()`.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
# NOTE: This file is auto-generated from 'scripts/error-docgen.mjs'
# Do not make edits to it directly, they will be overwritten.
# Instead, change this file: https://github.com/withastro/astro/blob/main/packages/astro/src/core/errors/errors-data.ts
# Translators, please remove this note and the <DontEditWarning/> component.

title: Astro couldn't find the correct page to render
i18nReady: true
githubURL: https://github.com/withastro/astro/blob/main/packages/astro/src/core/errors/errors-data.ts
---
import DontEditWarning from '~/components/DontEditWarning.astro'

<DontEditWarning />


> **FailedToFindPageMapSSR**: Astro couldn't find the correct page to render, probably because it wasn't correctly mapped for SSR usage. This is an internal error. Please file an issue.
## What went wrong?
Astro couldn't find the correct page to render, probably because it wasn't correctly mapped for SSR usage. This is an internal error.



Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import DontEditWarning from '~/components/DontEditWarning.astro'
<DontEditWarning />


> **FailedToLoadModuleSSR**: Could not import `IMPORT_NAME`. (E04001)
> **FailedToLoadModuleSSR**: Could not import `IMPORT_NAME`.
## What went wrong?
Astro could not import the requested file. Oftentimes, this is caused by the import path being wrong (either because the file does not exist, or there is a typo in the path)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import DontEditWarning from '~/components/DontEditWarning.astro'
<DontEditWarning />


> **GenerateContentTypesError**: `astro sync` command failed to generate content collection types: ERROR_MESSAGE (E08001)
> **GenerateContentTypesError**: `astro sync` command failed to generate content collection types: ERROR_MESSAGE
## What went wrong?
`astro sync` command failed to generate content collection types.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import DontEditWarning from '~/components/DontEditWarning.astro'
<DontEditWarning />


> **GetStaticPathsExpectedParams**: Missing or empty required `params` property on `getStaticPaths` route. (E03013)
> **GetStaticPathsExpectedParams**: Missing or empty required `params` property on `getStaticPaths` route.
## What went wrong?
Every route specified by `getStaticPaths` require a `params` property specifying the path parameters needed to match the route.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import DontEditWarning from '~/components/DontEditWarning.astro'
<DontEditWarning />


> **GetStaticPathsInvalidRouteParam**: Invalid getStaticPaths route parameter for `KEY`. Expected undefined, a string or a number, received `VALUE_TYPE` (`VALUE`) (E03014)
> **GetStaticPathsInvalidRouteParam**: Invalid getStaticPaths route parameter for `KEY`. Expected undefined, a string or a number, received `VALUE_TYPE` (`VALUE`)
## What went wrong?
Since `params` are encoded into the URL, only certain types are supported as values.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import DontEditWarning from '~/components/DontEditWarning.astro'
<DontEditWarning />


> **GetStaticPathsRemovedRSSHelper**: The RSS helper has been removed from `getStaticPaths`. Try the new @astrojs/rss package instead. (E03012)
> **GetStaticPathsRemovedRSSHelper**: The RSS helper has been removed from `getStaticPaths`. Try the new @astrojs/rss package instead.
## What went wrong?
`getStaticPaths` no longer expose an helper for generating a RSS feed. We recommend migrating to the [@astrojs/rss](/en/guides/rss/#setting-up-astrojsrss)integration instead.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import DontEditWarning from '~/components/DontEditWarning.astro'
<DontEditWarning />


> **GetStaticPathsRequired**: `getStaticPaths()` function is required for dynamic routes. Make sure that you `export` a `getStaticPaths` function from your dynamic route. (E03015)
> **GetStaticPathsRequired**: `getStaticPaths()` function is required for dynamic routes. Make sure that you `export` a `getStaticPaths` function from your dynamic route.
## What went wrong?
In [Static Mode](/en/core-concepts/routing/#static-ssg-mode), all routes must be determined at build time. As such, dynamic routes must `export` a `getStaticPaths` function returning the different paths to generate.
Expand Down
2 changes: 1 addition & 1 deletion src/content/docs/en/reference/errors/image-missing-alt.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import DontEditWarning from '~/components/DontEditWarning.astro'
<DontEditWarning />


> **ImageMissingAlt**: The alt property is required. (E03022)
> **ImageMissingAlt**: The alt property is required.
## What went wrong?
The `alt` property allows you to provide descriptive alt text to users of screen readers and other assistive technologies. In order to ensure your images are accessible, the `Image` component requires that an `alt` be specified.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import DontEditWarning from '~/components/DontEditWarning.astro'


> **Example error messages:**<br/>
InvalidComponentArgs: Invalid arguments passed to `<MyAstroComponent>` component. (E03020)
InvalidComponentArgs: Invalid arguments passed to `<MyAstroComponent>` component.
## What went wrong?
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
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import DontEditWarning from '~/components/DontEditWarning.astro'
> **Example error message:**<br/>
**blog** → **post.md** frontmatter does not match collection schema.<br/>
"title" is required.<br/>
"date" must be a valid date. (E09001)
"date" must be a valid date.

## What went wrong?
A Markdown or MDX entry in `src/content/` does not match its collection schema.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import DontEditWarning from '~/components/DontEditWarning.astro'
<DontEditWarning />


> `COLLECTION_NAME``ENTRY_ID` has an invalid slug. `slug` must be a string. (E09002)
> `COLLECTION_NAME``ENTRY_ID` has an invalid slug. `slug` must be a string.
## What went wrong?
An entry in `src/content/` has an invalid `slug`. This field is reserved for generating entry slugs, and must be a string when present.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import DontEditWarning from '~/components/DontEditWarning.astro'
<DontEditWarning />


> **InvalidDynamicRoute**: The INVALID_PARAM param for route ROUTE is invalid. Received **RECEIVED**. (E03038)
> **InvalidDynamicRoute**: The INVALID_PARAM param for route ROUTE is invalid. Received **RECEIVED**.
## What went wrong?
A dynamic route param is invalid. This is often caused by an `undefined` parameter or a missing [rest parameter](/en/core-concepts/routing/#rest-parameters).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import DontEditWarning from '~/components/DontEditWarning.astro'
<DontEditWarning />


> **InvalidFrontmatterInjectionError**: A remark or rehype plugin attempted to inject invalid frontmatter. Ensure "astro.frontmatter" is set to a valid JSON object that is not `null` or `undefined`. (E06003)
> **InvalidFrontmatterInjectionError**: A remark or rehype plugin attempted to inject invalid frontmatter. Ensure "astro.frontmatter" is set to a valid JSON object that is not `null` or `undefined`.
## What went wrong?
A remark or rehype plugin attempted to inject invalid frontmatter. This occurs when "astro.frontmatter" is set to `null`, `undefined`, or an invalid JSON object.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import DontEditWarning from '~/components/DontEditWarning.astro'
<DontEditWarning />


> **InvalidGetStaticPathParam**: Invalid params given to `getStaticPaths` path. Expected an `object`, got `PARAM_TYPE` (E03010)
> **InvalidGetStaticPathParam**: Invalid params given to `getStaticPaths` path. Expected an `object`, got `PARAM_TYPE`
## What went wrong?
The `params` property in `getStaticPaths`'s return value (an array of objects) should also be an object.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import DontEditWarning from '~/components/DontEditWarning.astro'
<DontEditWarning />


> **InvalidGetStaticPathsReturn**: Invalid type returned by `getStaticPaths`. Expected an `array`, got `RETURN_TYPE` (E03011)
> **InvalidGetStaticPathsReturn**: Invalid type returned by `getStaticPaths`. Expected an `array`, got `RETURN_TYPE`
## What went wrong?
`getStaticPaths`'s return value must be an array of objects.
Expand Down
2 changes: 1 addition & 1 deletion src/content/docs/en/reference/errors/invalid-glob.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import DontEditWarning from '~/components/DontEditWarning.astro'
<DontEditWarning />


> **InvalidGlob**: Invalid glob pattern: `GLOB_PATTERN`. Glob patterns must start with './', '../' or '/'. (E04002)
> **InvalidGlob**: Invalid glob pattern: `GLOB_PATTERN`. Glob patterns must start with './', '../' or '/'.
## What went wrong?
Astro encountered an invalid glob pattern. This is often caused by the glob pattern not being a valid file path.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import DontEditWarning from '~/components/DontEditWarning.astro'
<DontEditWarning />


> **InvalidImageService**: There was an error loading the configured image service. Please see the stack trace for more information. (E03023)
> **InvalidImageService**: There was an error loading the configured image service. Please see the stack trace for more information.
## What went wrong?
There was an error while loading the configured image service. This can be caused by various factors, such as your image service not properly exporting a compatible object in its default export, or an incorrect path.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import DontEditWarning from '~/components/DontEditWarning.astro'


> **Example error messages:**<br/>
InvalidPrerenderExport: A `prerender` export has been detected, but its value cannot be statically analyzed. (E03019)
InvalidPrerenderExport: A `prerender` export has been detected, but its value cannot be statically analyzed.

## What went wrong?
The `prerender` feature only supports a subset of valid JavaScript — be sure to use exactly `export const prerender = true` so that our compiler can detect this directive at build time. Variables, `let`, and `var` declarations are not supported.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import DontEditWarning from '~/components/DontEditWarning.astro'
<DontEditWarning />


> **LocalImageUsedWrongly**: `Image`'s and `getImage`'s `src` parameter must be an imported image or an URL, it cannot be a filepath. Received `IMAGE_FILE_PATH`. (E03034)
> **LocalImageUsedWrongly**: `Image`'s and `getImage`'s `src` parameter must be an imported image or an URL, it cannot be a filepath. Received `IMAGE_FILE_PATH`.
## What went wrong?
When using the default image services, `Image`'s and `getImage`'s `src` parameter must be either an imported image or an URL, it cannot be a filepath.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import DontEditWarning from '~/components/DontEditWarning.astro'
<DontEditWarning />


> **LocalsNotAnObject**: `locals` can only be assigned to an object. Other values like numbers, strings, etc. are not accepted. (E03033)
> **LocalsNotAnObject**: `locals` can only be assigned to an object. Other values like numbers, strings, etc. are not accepted.
## What went wrong?
Thrown in development mode when `locals` is overwritten with something that is not an object
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,10 @@ import DontEditWarning from '~/components/DontEditWarning.astro'
> **Example error message:**<br/>
Could not parse frontmatter in **blog** → **post.md**<br/>
"title" is required.<br/>
"date" must be a valid date. (E06002)
"date" must be a valid date.

## What went wrong?
A Markdown document's frontmatter in `src/content/` does not match its collection schema.
Make sure that all required fields are present, and that all fields are of the correct type.
You can check against the collection schema in your `src/content/config.*` file.
See the [Content collections documentation](/en/guides/content-collections/) for more information.



Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import DontEditWarning from '~/components/DontEditWarning.astro'
> **Example error messages:**<br/>
can not read an implicit mapping pair; a colon is missed<br/>
unexpected end of the stream within a double quoted scalar<br/>
can not read a block mapping entry; a multiline key may not be an implicit key (E06001)
can not read a block mapping entry; a multiline key may not be an implicit key

## What went wrong?
Astro encountered an error while parsing the frontmatter of your Markdown file.
Expand Down
Loading

0 comments on commit 82dff82

Please sign in to comment.