feat: break down AstroErrorData
in multiple objects
This commit is contained in:
parent
93ad8b95e3
commit
46974b64e7
43 changed files with 1226 additions and 1154 deletions
|
@ -1,6 +1,7 @@
|
||||||
---
|
---
|
||||||
import { getImage, type LocalImageProps, type RemoteImageProps } from 'astro:assets';
|
import { getImage, type LocalImageProps, type RemoteImageProps } from 'astro:assets';
|
||||||
import { AstroError, AstroErrorData } from '../dist/core/errors/index.js';
|
import { AstroError } from '../dist/core/errors/index.js';
|
||||||
|
import { ImageMissingAlt } from '../dist/core/errors/errors-data.js';
|
||||||
|
|
||||||
// The TypeScript diagnostic for JSX props uses the last member of the union to suggest props, so it would be better for
|
// The TypeScript diagnostic for JSX props uses the last member of the union to suggest props, so it would be better for
|
||||||
// LocalImageProps to be last. Unfortunately, when we do this the error messages that remote images get are complete nonsense
|
// LocalImageProps to be last. Unfortunately, when we do this the error messages that remote images get are complete nonsense
|
||||||
|
@ -10,7 +11,7 @@ type Props = LocalImageProps | RemoteImageProps;
|
||||||
const props = Astro.props;
|
const props = Astro.props;
|
||||||
|
|
||||||
if (props.alt === undefined || props.alt === null) {
|
if (props.alt === undefined || props.alt === null) {
|
||||||
throw new AstroError(AstroErrorData.ImageMissingAlt);
|
throw new AstroError(ImageMissingAlt);
|
||||||
}
|
}
|
||||||
|
|
||||||
// As a convenience, allow width and height to be string with a number in them, to match HTML's native `img`.
|
// As a convenience, allow width and height to be string with a number in them, to match HTML's native `img`.
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import type { AstroSettings } from '../@types/astro.js';
|
import type { AstroSettings } from '../@types/astro.js';
|
||||||
import { AstroError, AstroErrorData } from '../core/errors/index.js';
|
import { AstroError } from '../core/errors/index.js';
|
||||||
|
import * as AstroErrorData from '../core/errors/errors-data.js';
|
||||||
import { isLocalService, type ImageService } from './services/service.js';
|
import { isLocalService, type ImageService } from './services/service.js';
|
||||||
import type { GetImageResult, ImageMetadata, ImageTransform } from './types.js';
|
import type { GetImageResult, ImageMetadata, ImageTransform } from './types.js';
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import { AstroError, AstroErrorData } from '../../core/errors/index.js';
|
import { AstroError } from '../../core/errors/index.js';
|
||||||
|
import * as AstroErrorData from '../../core/errors/errors-data.js';
|
||||||
import { joinPaths } from '../../core/path.js';
|
import { joinPaths } from '../../core/path.js';
|
||||||
import { VALID_SUPPORTED_FORMATS } from '../consts.js';
|
import { VALID_SUPPORTED_FORMATS } from '../consts.js';
|
||||||
import { isESMImportedImage } from '../internal.js';
|
import { isESMImportedImage } from '../internal.js';
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import type { MarkdownHeading } from '@astrojs/markdown-remark';
|
import type { MarkdownHeading } from '@astrojs/markdown-remark';
|
||||||
import { ZodIssueCode, string as zodString } from 'zod';
|
import { ZodIssueCode, string as zodString } from 'zod';
|
||||||
import { AstroError, AstroErrorData } from '../core/errors/index.js';
|
import { AstroError } from '../core/errors/index.js';
|
||||||
|
import * as AstroErrorData from '../core/errors/errors-data.js';
|
||||||
import { prependForwardSlash } from '../core/path.js';
|
import { prependForwardSlash } from '../core/path.js';
|
||||||
import {
|
import {
|
||||||
createComponent,
|
createComponent,
|
||||||
|
|
|
@ -5,7 +5,7 @@ import * as path from 'node:path';
|
||||||
import { fileURLToPath, pathToFileURL } from 'node:url';
|
import { fileURLToPath, pathToFileURL } from 'node:url';
|
||||||
import { normalizePath, type ViteDevServer } from 'vite';
|
import { normalizePath, type ViteDevServer } from 'vite';
|
||||||
import type { AstroSettings, ContentEntryType } from '../@types/astro.js';
|
import type { AstroSettings, ContentEntryType } from '../@types/astro.js';
|
||||||
import { AstroErrorData } from '../core/errors/errors-data.js';
|
import * as AstroErrorData from '../core/errors/errors-data.js';
|
||||||
import { AstroError } from '../core/errors/errors.js';
|
import { AstroError } from '../core/errors/errors.js';
|
||||||
import { info, warn, type LogOptions } from '../core/logger/core.js';
|
import { info, warn, type LogOptions } from '../core/logger/core.js';
|
||||||
import { isRelativePath } from '../core/path.js';
|
import { isRelativePath } from '../core/path.js';
|
||||||
|
|
|
@ -14,7 +14,8 @@ import type {
|
||||||
ImageInputFormat,
|
ImageInputFormat,
|
||||||
} from '../@types/astro.js';
|
} from '../@types/astro.js';
|
||||||
import { VALID_INPUT_FORMATS } from '../assets/consts.js';
|
import { VALID_INPUT_FORMATS } from '../assets/consts.js';
|
||||||
import { AstroError, AstroErrorData } from '../core/errors/index.js';
|
import { AstroError } from '../core/errors/index.js';
|
||||||
|
import * as AstroErrorData from '../core/errors/errors-data.js';
|
||||||
|
|
||||||
import { formatYAMLException, isYAMLException } from '../core/errors/utils.js';
|
import { formatYAMLException, isYAMLException } from '../core/errors/utils.js';
|
||||||
import { CONTENT_FLAGS, CONTENT_TYPES_FILE } from './consts.js';
|
import { CONTENT_FLAGS, CONTENT_TYPES_FILE } from './consts.js';
|
||||||
|
|
|
@ -12,7 +12,7 @@ import type {
|
||||||
DataEntryModule,
|
DataEntryModule,
|
||||||
DataEntryType,
|
DataEntryType,
|
||||||
} from '../@types/astro.js';
|
} from '../@types/astro.js';
|
||||||
import { AstroErrorData } from '../core/errors/errors-data.js';
|
import * as AstroErrorData from '../core/errors/errors-data.js';
|
||||||
import { AstroError } from '../core/errors/errors.js';
|
import { AstroError } from '../core/errors/errors.js';
|
||||||
import { escapeViteEnvReferences } from '../vite-plugin-utils/index.js';
|
import { escapeViteEnvReferences } from '../vite-plugin-utils/index.js';
|
||||||
import { CONTENT_FLAG, DATA_FLAG } from './consts.js';
|
import { CONTENT_FLAG, DATA_FLAG } from './consts.js';
|
||||||
|
@ -371,6 +371,7 @@ function stringifyEntryData(data: Record<string, any>): string {
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
throw new AstroError({
|
throw new AstroError({
|
||||||
|
name: 'ContentImportsPluginError',
|
||||||
message: 'Unexpected error processing content collection data.',
|
message: 'Unexpected error processing content collection data.',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,8 @@ import { fileURLToPath, pathToFileURL } from 'node:url';
|
||||||
import pLimit from 'p-limit';
|
import pLimit from 'p-limit';
|
||||||
import type { Plugin } from 'vite';
|
import type { Plugin } from 'vite';
|
||||||
import type { AstroSettings, ContentEntryType } from '../@types/astro.js';
|
import type { AstroSettings, ContentEntryType } from '../@types/astro.js';
|
||||||
import { AstroError, AstroErrorData } from '../core/errors/index.js';
|
import { AstroError } from '../core/errors/index.js';
|
||||||
|
import * as AstroErrorData from '../core/errors/errors-data.js';
|
||||||
import { appendForwardSlash } from '../core/path.js';
|
import { appendForwardSlash } from '../core/path.js';
|
||||||
import { rootRelativePath } from '../core/util.js';
|
import { rootRelativePath } from '../core/util.js';
|
||||||
import { VIRTUAL_MODULE_ID } from './consts.js';
|
import { VIRTUAL_MODULE_ID } from './consts.js';
|
||||||
|
|
|
@ -35,7 +35,8 @@ import {
|
||||||
import { runHookBuildGenerated } from '../../integrations/index.js';
|
import { runHookBuildGenerated } from '../../integrations/index.js';
|
||||||
import { isServerLikeOutput } from '../../prerender/utils.js';
|
import { isServerLikeOutput } from '../../prerender/utils.js';
|
||||||
import { BEFORE_HYDRATION_SCRIPT_ID, PAGE_SCRIPT_ID } from '../../vite-plugin-scripts/index.js';
|
import { BEFORE_HYDRATION_SCRIPT_ID, PAGE_SCRIPT_ID } from '../../vite-plugin-scripts/index.js';
|
||||||
import { AstroError, AstroErrorData } from '../errors/index.js';
|
import { AstroError } from '../errors/index.js';
|
||||||
|
import * as AstroErrorData from '../errors/errors-data.js';
|
||||||
import { debug, info } from '../logger/core.js';
|
import { debug, info } from '../logger/core.js';
|
||||||
import { RedirectSinglePageBuiltModule, getRedirectLocationOrThrow } from '../redirects/index.js';
|
import { RedirectSinglePageBuiltModule, getRedirectLocationOrThrow } from '../redirects/index.js';
|
||||||
import { isEndpointResult } from '../render/core.js';
|
import { isEndpointResult } from '../render/core.js';
|
||||||
|
|
|
@ -12,13 +12,14 @@ import {
|
||||||
eachPageData,
|
eachPageData,
|
||||||
type BuildInternals,
|
type BuildInternals,
|
||||||
} from '../../core/build/internal.js';
|
} from '../../core/build/internal.js';
|
||||||
|
import * as AstroErrorData from '../errors/errors-data.js';
|
||||||
import { emptyDir, removeEmptyDirs } from '../../core/fs/index.js';
|
import { emptyDir, removeEmptyDirs } from '../../core/fs/index.js';
|
||||||
import { appendForwardSlash, prependForwardSlash } from '../../core/path.js';
|
import { appendForwardSlash, prependForwardSlash } from '../../core/path.js';
|
||||||
import { isModeServerWithNoAdapter } from '../../core/util.js';
|
import { isModeServerWithNoAdapter } from '../../core/util.js';
|
||||||
import { runHookBuildSetup } from '../../integrations/index.js';
|
import { runHookBuildSetup } from '../../integrations/index.js';
|
||||||
import { isServerLikeOutput } from '../../prerender/utils.js';
|
import { isServerLikeOutput } from '../../prerender/utils.js';
|
||||||
import { PAGE_SCRIPT_ID } from '../../vite-plugin-scripts/index.js';
|
import { PAGE_SCRIPT_ID } from '../../vite-plugin-scripts/index.js';
|
||||||
import { AstroError, AstroErrorData } from '../errors/index.js';
|
import { AstroError } from '../errors/index.js';
|
||||||
import { info } from '../logger/core.js';
|
import { info } from '../logger/core.js';
|
||||||
import { routeIsRedirect } from '../redirects/index.js';
|
import { routeIsRedirect } from '../redirects/index.js';
|
||||||
import { getOutDirWithinCwd } from './common.js';
|
import { getOutDirWithinCwd } from './common.js';
|
||||||
|
|
|
@ -1,12 +1,11 @@
|
||||||
import type { TransformResult } from '@astrojs/compiler';
|
import type { TransformResult } from '@astrojs/compiler';
|
||||||
import type { ResolvedConfig } from 'vite';
|
import type { ResolvedConfig } from 'vite';
|
||||||
import type { AstroConfig } from '../../@types/astro';
|
import type { AstroConfig } from '../../@types/astro';
|
||||||
|
import * as AstroErrorData from '../errors/errors-data.js';
|
||||||
import { transform } from '@astrojs/compiler';
|
import { transform } from '@astrojs/compiler';
|
||||||
import { fileURLToPath } from 'node:url';
|
import { fileURLToPath } from 'node:url';
|
||||||
import { normalizePath } from 'vite';
|
import { normalizePath } from 'vite';
|
||||||
import { AggregateError, AstroError, CompilerError } from '../errors/errors.js';
|
import { AggregateError, AstroError, CompilerError } from '../errors/errors.js';
|
||||||
import { AstroErrorData } from '../errors/index.js';
|
|
||||||
import { resolvePath } from '../util.js';
|
import { resolvePath } from '../util.js';
|
||||||
import { createStylePreprocessor } from './style.js';
|
import { createStylePreprocessor } from './style.js';
|
||||||
|
|
||||||
|
@ -87,6 +86,7 @@ function handleCompileResultErrors(result: TransformResult, cssTransformErrors:
|
||||||
|
|
||||||
if (compilerError) {
|
if (compilerError) {
|
||||||
throw new CompilerError({
|
throw new CompilerError({
|
||||||
|
name: 'CompilerError',
|
||||||
message: compilerError.text,
|
message: compilerError.text,
|
||||||
location: {
|
location: {
|
||||||
line: compilerError.location.line,
|
line: compilerError.location.line,
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
import type { TransformOptions } from '@astrojs/compiler';
|
import type { TransformOptions } from '@astrojs/compiler';
|
||||||
import fs from 'node:fs';
|
import fs from 'node:fs';
|
||||||
import { preprocessCSS, type ResolvedConfig } from 'vite';
|
import { preprocessCSS, type ResolvedConfig } from 'vite';
|
||||||
import { AstroErrorData, CSSError, positionAt } from '../errors/index.js';
|
import { CSSError, positionAt } from '../errors/index.js';
|
||||||
|
import * as AstroErrorData from '../errors/errors-data.js';
|
||||||
|
|
||||||
export function createStylePreprocessor({
|
export function createStylePreprocessor({
|
||||||
filename,
|
filename,
|
||||||
|
@ -88,6 +89,7 @@ function enhanceCSSError(err: any, filename: string, cssContent: string) {
|
||||||
errorPosition.line += 1;
|
errorPosition.line += 1;
|
||||||
|
|
||||||
return new CSSError({
|
return new CSSError({
|
||||||
|
name: 'CSSError',
|
||||||
message: err.message,
|
message: err.message,
|
||||||
location: {
|
location: {
|
||||||
file: filename,
|
file: filename,
|
||||||
|
|
|
@ -6,7 +6,7 @@ import type {
|
||||||
AstroUserConfig,
|
AstroUserConfig,
|
||||||
CLIFlags,
|
CLIFlags,
|
||||||
} from '../../@types/astro';
|
} from '../../@types/astro';
|
||||||
|
import * as AstroErrorData from '../errors/errors-data.js';
|
||||||
import * as colors from 'kleur/colors';
|
import * as colors from 'kleur/colors';
|
||||||
import fs from 'node:fs';
|
import fs from 'node:fs';
|
||||||
import path from 'node:path';
|
import path from 'node:path';
|
||||||
|
@ -14,7 +14,7 @@ import { fileURLToPath } from 'node:url';
|
||||||
import { ZodError } from 'zod';
|
import { ZodError } from 'zod';
|
||||||
import { eventConfigError, telemetry } from '../../events/index.js';
|
import { eventConfigError, telemetry } from '../../events/index.js';
|
||||||
import { trackAstroConfigZodError } from '../errors/errors.js';
|
import { trackAstroConfigZodError } from '../errors/errors.js';
|
||||||
import { AstroError, AstroErrorData } from '../errors/index.js';
|
import { AstroError } from '../errors/index.js';
|
||||||
import { formatConfigErrorMessage } from '../messages.js';
|
import { formatConfigErrorMessage } from '../messages.js';
|
||||||
import { mergeConfig } from './merge.js';
|
import { mergeConfig } from './merge.js';
|
||||||
import { createRelativeSchema } from './schema.js';
|
import { createRelativeSchema } from './schema.js';
|
||||||
|
|
|
@ -6,7 +6,8 @@ import { getContentPaths } from '../../content/index.js';
|
||||||
import jsxRenderer from '../../jsx/renderer.js';
|
import jsxRenderer from '../../jsx/renderer.js';
|
||||||
import { markdownContentEntryType } from '../../vite-plugin-markdown/content-entry-type.js';
|
import { markdownContentEntryType } from '../../vite-plugin-markdown/content-entry-type.js';
|
||||||
import { getDefaultClientDirectives } from '../client-directive/index.js';
|
import { getDefaultClientDirectives } from '../client-directive/index.js';
|
||||||
import { AstroError, AstroErrorData } from '../errors/index.js';
|
import { AstroError } from '../errors/index.js';
|
||||||
|
import * as AstroErrorData from '../errors/errors-data.js';
|
||||||
import { formatYAMLException, isYAMLException } from '../errors/utils.js';
|
import { formatYAMLException, isYAMLException } from '../errors/utils.js';
|
||||||
import { SUPPORTED_MARKDOWN_FILE_EXTENSIONS } from './../constants.js';
|
import { SUPPORTED_MARKDOWN_FILE_EXTENSIONS } from './../constants.js';
|
||||||
import { AstroTimer } from './timer.js';
|
import { AstroTimer } from './timer.js';
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import type { CookieSerializeOptions } from 'cookie';
|
import type { CookieSerializeOptions } from 'cookie';
|
||||||
import { parse, serialize } from 'cookie';
|
import { parse, serialize } from 'cookie';
|
||||||
import { AstroError, AstroErrorData } from '../errors/index.js';
|
import { AstroError } from '../errors/index.js';
|
||||||
|
import * as AstroErrorData from '../errors/errors-data.js';
|
||||||
|
|
||||||
interface AstroCookieSetOptions {
|
interface AstroCookieSetOptions {
|
||||||
domain?: string;
|
domain?: string;
|
||||||
|
|
|
@ -10,9 +10,10 @@ import type { Environment, RenderContext } from '../render/index';
|
||||||
import { renderEndpoint } from '../../runtime/server/index.js';
|
import { renderEndpoint } from '../../runtime/server/index.js';
|
||||||
import { ASTRO_VERSION } from '../constants.js';
|
import { ASTRO_VERSION } from '../constants.js';
|
||||||
import { AstroCookies, attachToResponse } from '../cookies/index.js';
|
import { AstroCookies, attachToResponse } from '../cookies/index.js';
|
||||||
import { AstroError, AstroErrorData } from '../errors/index.js';
|
import { AstroError } from '../errors/index.js';
|
||||||
import { warn } from '../logger/core.js';
|
import { warn } from '../logger/core.js';
|
||||||
import { callMiddleware } from '../middleware/callMiddleware.js';
|
import { callMiddleware } from '../middleware/callMiddleware.js';
|
||||||
|
import * as AstroErrorData from '../errors/errors-data.js';
|
||||||
|
|
||||||
const clientAddressSymbol = Symbol.for('astro.clientAddress');
|
const clientAddressSymbol = Symbol.for('astro.clientAddress');
|
||||||
const clientLocalsSymbol = Symbol.for('astro.locals');
|
const clientLocalsSymbol = Symbol.for('astro.locals');
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
|
|
||||||
**Error Format**
|
**Error Format**
|
||||||
|
|
||||||
Name (key of the object definition):
|
Name:
|
||||||
|
|
||||||
- This property is a static reference to the error. The shape should be similar to JavaScript's native errors (TypeError, ReferenceError): pascal-cased, no spaces, no special characters etc. (ex: `ClientAddressNotAvailable`)
|
- This property is a static reference to the error. The shape should be similar to JavaScript's native errors (TypeError, ReferenceError): pascal-cased, no spaces, no special characters etc. (ex: `ClientAddressNotAvailable`)
|
||||||
- This is the only part of the error message that should not be written as a full, proper sentence complete with Capitalization and end punctuation.
|
- This is the only part of the error message that should not be written as a full, proper sentence complete with Capitalization and end punctuation.
|
||||||
|
@ -19,8 +19,8 @@ Title:
|
||||||
|
|
||||||
Message:
|
Message:
|
||||||
|
|
||||||
- Begin with **what happened** and **why**. (ex: `Could not use {feature} because Server-side Rendering is not enabled.`)
|
- Begin with **what happened** and **why**. (ex: `Could not use {feature} because Server-side Rendering is not enabled.`)
|
||||||
- Then, **describe the action the user should take**. (ex: `Update your Astro config with `output: 'server'` to enable Server-side Rendering.`)
|
- Then, **describe the action the user should take**. (ex: `Update your Astro config with `output: 'server'` to enable Server-side Rendering.`)
|
||||||
- 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.
|
- 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.
|
||||||
- Instead of writing a longer message, consider using a `hint`.
|
- Instead of writing a longer message, consider using a `hint`.
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ import { fileURLToPath } from 'node:url';
|
||||||
import { getHighlighter } from 'shiki';
|
import { getHighlighter } from 'shiki';
|
||||||
import type { ErrorPayload } from 'vite';
|
import type { ErrorPayload } from 'vite';
|
||||||
import type { ModuleLoader } from '../../module-loader/index.js';
|
import type { ModuleLoader } from '../../module-loader/index.js';
|
||||||
import { AstroErrorData } from '../errors-data.js';
|
import { FailedToLoadModuleSSR, InvalidGlob, MdxIntegrationMissingError } from '../errors-data.js';
|
||||||
import { AstroError, type ErrorWithMetadata } from '../errors.js';
|
import { AstroError, type ErrorWithMetadata } from '../errors.js';
|
||||||
import { createSafeError } from '../utils.js';
|
import { createSafeError } from '../utils.js';
|
||||||
import type { SSRLoadedRenderer } from './../../../@types/astro.js';
|
import type { SSRLoadedRenderer } from './../../../@types/astro.js';
|
||||||
|
@ -41,10 +41,10 @@ export function enhanceViteSSRError({
|
||||||
// https://github.com/vitejs/vite/blob/ee7c28a46a6563d54b828af42570c55f16b15d2c/packages/vite/src/node/ssr/ssrModuleLoader.ts#L91
|
// https://github.com/vitejs/vite/blob/ee7c28a46a6563d54b828af42570c55f16b15d2c/packages/vite/src/node/ssr/ssrModuleLoader.ts#L91
|
||||||
let importName: string | undefined;
|
let importName: string | undefined;
|
||||||
if ((importName = safeError.message.match(/Failed to load url (.*?) \(resolved id:/)?.[1])) {
|
if ((importName = safeError.message.match(/Failed to load url (.*?) \(resolved id:/)?.[1])) {
|
||||||
safeError.title = AstroErrorData.FailedToLoadModuleSSR.title;
|
safeError.title = FailedToLoadModuleSSR.title;
|
||||||
safeError.name = 'FailedToLoadModuleSSR';
|
safeError.name = 'FailedToLoadModuleSSR';
|
||||||
safeError.message = AstroErrorData.FailedToLoadModuleSSR.message(importName);
|
safeError.message = FailedToLoadModuleSSR.message(importName);
|
||||||
safeError.hint = AstroErrorData.FailedToLoadModuleSSR.hint;
|
safeError.hint = FailedToLoadModuleSSR.hint;
|
||||||
const line = lns.findIndex((ln) => ln.includes(importName!));
|
const line = lns.findIndex((ln) => ln.includes(importName!));
|
||||||
|
|
||||||
if (line !== -1) {
|
if (line !== -1) {
|
||||||
|
@ -68,8 +68,8 @@ export function enhanceViteSSRError({
|
||||||
fileId?.match(/\.mdx$/)
|
fileId?.match(/\.mdx$/)
|
||||||
) {
|
) {
|
||||||
safeError = new AstroError({
|
safeError = new AstroError({
|
||||||
...AstroErrorData.MdxIntegrationMissingError,
|
...MdxIntegrationMissingError,
|
||||||
message: AstroErrorData.MdxIntegrationMissingError.message(JSON.stringify(fileId)),
|
message: MdxIntegrationMissingError.message(JSON.stringify(fileId)),
|
||||||
location: safeError.loc,
|
location: safeError.loc,
|
||||||
stack: safeError.stack,
|
stack: safeError.stack,
|
||||||
}) as ErrorWithMetadata;
|
}) as ErrorWithMetadata;
|
||||||
|
@ -80,10 +80,10 @@ export function enhanceViteSSRError({
|
||||||
const globPattern = safeError.message.match(/glob: "(.+)" \(/)?.[1];
|
const globPattern = safeError.message.match(/glob: "(.+)" \(/)?.[1];
|
||||||
|
|
||||||
if (globPattern) {
|
if (globPattern) {
|
||||||
safeError.message = AstroErrorData.InvalidGlob.message(globPattern);
|
safeError.message = InvalidGlob.message(globPattern);
|
||||||
safeError.name = 'InvalidGlob';
|
safeError.name = 'InvalidGlob';
|
||||||
safeError.hint = AstroErrorData.InvalidGlob.hint;
|
safeError.hint = InvalidGlob.hint;
|
||||||
safeError.title = AstroErrorData.InvalidGlob.title;
|
safeError.title = InvalidGlob.title;
|
||||||
|
|
||||||
const line = lns.findIndex((ln) => ln.includes(globPattern));
|
const line = lns.findIndex((ln) => ln.includes(globPattern));
|
||||||
|
|
||||||
|
@ -137,7 +137,7 @@ export async function getViteErrorPayload(err: ErrorWithMetadata): Promise<Astro
|
||||||
const message = renderErrorMarkdown(err.message.trim(), 'html');
|
const message = renderErrorMarkdown(err.message.trim(), 'html');
|
||||||
const hint = err.hint ? renderErrorMarkdown(err.hint.trim(), 'html') : undefined;
|
const hint = err.hint ? renderErrorMarkdown(err.hint.trim(), 'html') : undefined;
|
||||||
|
|
||||||
const hasDocs = err.name in AstroErrorData;
|
const hasDocs = !!err.name;
|
||||||
const docslink = hasDocs
|
const docslink = hasDocs
|
||||||
? `https://docs.astro.build/en/reference/errors/${getKebabErrorName(err.name)}/`
|
? `https://docs.astro.build/en/reference/errors/${getKebabErrorName(err.name)}/`
|
||||||
: undefined;
|
: undefined;
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,10 +1,9 @@
|
||||||
import type { ZodError } from 'zod';
|
import type { ZodError } from 'zod';
|
||||||
import { codeFrame } from './printer.js';
|
import { codeFrame } from './printer.js';
|
||||||
import { getErrorDataByTitle } from './utils.js';
|
|
||||||
|
|
||||||
interface ErrorProperties {
|
interface ErrorProperties {
|
||||||
title?: string;
|
title?: string;
|
||||||
name?: string;
|
name: string;
|
||||||
message?: string;
|
message?: string;
|
||||||
location?: ErrorLocation;
|
location?: ErrorLocation;
|
||||||
hint?: string;
|
hint?: string;
|
||||||
|
@ -43,16 +42,7 @@ export class AstroError extends Error {
|
||||||
|
|
||||||
const { name, title, message, stack, location, hint, frame } = props;
|
const { name, title, message, stack, location, hint, frame } = props;
|
||||||
this.title = title;
|
this.title = title;
|
||||||
|
this.name = name;
|
||||||
if (name && name !== 'Error') {
|
|
||||||
this.name = name;
|
|
||||||
} else if (this.title) {
|
|
||||||
const errorData = getErrorDataByTitle(this.title)?.name;
|
|
||||||
|
|
||||||
if (errorData) {
|
|
||||||
this.name = errorData;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (message) this.message = message;
|
if (message) this.message = message;
|
||||||
// Only set this if we actually have a stack passed, otherwise uses Error's
|
// Only set this if we actually have a stack passed, otherwise uses Error's
|
||||||
|
@ -92,8 +82,6 @@ export class CompilerError extends AstroError {
|
||||||
|
|
||||||
constructor(props: ErrorProperties, ...params: any) {
|
constructor(props: ErrorProperties, ...params: any) {
|
||||||
super(props, ...params);
|
super(props, ...params);
|
||||||
|
|
||||||
this.name = 'CompilerError';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static is(err: unknown): err is CompilerError {
|
static is(err: unknown): err is CompilerError {
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
export type { ErrorLocation, ErrorWithMetadata } from './errors';
|
export type { ErrorLocation, ErrorWithMetadata } from './errors';
|
||||||
export { AstroErrorData } from './errors-data.js';
|
|
||||||
export {
|
export {
|
||||||
AggregateError,
|
AggregateError,
|
||||||
AstroError,
|
AstroError,
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
import type { YAMLException } from 'js-yaml';
|
import type { YAMLException } from 'js-yaml';
|
||||||
import type { ErrorPayload as ViteErrorPayload } from 'vite';
|
import type { ErrorPayload as ViteErrorPayload } from 'vite';
|
||||||
import type { SSRError } from '../../@types/astro.js';
|
import type { SSRError } from '../../@types/astro.js';
|
||||||
import { AstroErrorData, type ErrorData } from './errors-data.js';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the line and character based on the offset
|
* Get the line and character based on the offset
|
||||||
|
@ -105,14 +104,3 @@ export function createSafeError(err: any): Error {
|
||||||
export function normalizeLF(code: string) {
|
export function normalizeLF(code: string) {
|
||||||
return code.replace(/\r\n|\r(?!\n)|\n/g, '\n');
|
return code.replace(/\r\n|\r(?!\n)|\n/g, '\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getErrorDataByTitle(title: string) {
|
|
||||||
const entry = Object.entries(AstroErrorData).find((data) => data[1].title === title);
|
|
||||||
|
|
||||||
if (entry) {
|
|
||||||
return {
|
|
||||||
name: entry[0],
|
|
||||||
data: entry[1] as ErrorData,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -5,9 +5,10 @@ import type {
|
||||||
MiddlewareHandler,
|
MiddlewareHandler,
|
||||||
MiddlewareNext,
|
MiddlewareNext,
|
||||||
} from '../../@types/astro';
|
} from '../../@types/astro';
|
||||||
import { AstroError, AstroErrorData } from '../errors/index.js';
|
import { AstroError } from '../errors/index.js';
|
||||||
import { warn } from '../logger/core.js';
|
import { warn } from '../logger/core.js';
|
||||||
import type { Environment } from '../render';
|
import type { Environment } from '../render';
|
||||||
|
import * as AstroErrorData from '../errors/errors-data.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Utility function that is in charge of calling the middleware.
|
* Utility function that is in charge of calling the middleware.
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import { AstroError, AstroErrorData } from '../errors/index.js';
|
import { AstroError } from '../errors/index.js';
|
||||||
|
import * as AstroErrorData from '../errors/errors-data.js';
|
||||||
|
|
||||||
export function getRedirectLocationOrThrow(headers: Headers): string {
|
export function getRedirectLocationOrThrow(headers: Headers): string {
|
||||||
let location = headers.get('location');
|
let location = headers.get('location');
|
||||||
|
|
|
@ -6,9 +6,10 @@ import type {
|
||||||
SSRElement,
|
SSRElement,
|
||||||
SSRResult,
|
SSRResult,
|
||||||
} from '../../@types/astro';
|
} from '../../@types/astro';
|
||||||
import { AstroError, AstroErrorData } from '../errors/index.js';
|
import { AstroError } from '../errors/index.js';
|
||||||
import type { Environment } from './environment';
|
import type { Environment } from './environment';
|
||||||
import { getParamsAndProps } from './params-and-props.js';
|
import { getParamsAndProps } from './params-and-props.js';
|
||||||
|
import * as AstroErrorData from '../errors/errors-data.js';
|
||||||
|
|
||||||
const clientLocalsSymbol = Symbol.for('astro.locals');
|
const clientLocalsSymbol = Symbol.for('astro.locals');
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,8 @@ import type {
|
||||||
Props,
|
Props,
|
||||||
RouteData,
|
RouteData,
|
||||||
} from '../../@types/astro';
|
} from '../../@types/astro';
|
||||||
import { AstroError, AstroErrorData } from '../errors/index.js';
|
import { AstroError } from '../errors/index.js';
|
||||||
|
import * as AstroErrorData from '../errors/errors-data.js';
|
||||||
|
|
||||||
export function generatePaginateFunction(routeMatch: RouteData): PaginateFunction {
|
export function generatePaginateFunction(routeMatch: RouteData): PaginateFunction {
|
||||||
return function paginateUtility(
|
return function paginateUtility(
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
import type { ComponentInstance, Params, Props, RouteData } from '../../@types/astro';
|
import type { ComponentInstance, Params, Props, RouteData } from '../../@types/astro';
|
||||||
import { AstroError, AstroErrorData } from '../errors/index.js';
|
import { AstroError } from '../errors/index.js';
|
||||||
import type { LogOptions } from '../logger/core.js';
|
import type { LogOptions } from '../logger/core.js';
|
||||||
import { getParams } from '../routing/params.js';
|
import { getParams } from '../routing/params.js';
|
||||||
import { RouteCache, callGetStaticPaths, findPathItemByKey } from './route-cache.js';
|
import { RouteCache, callGetStaticPaths, findPathItemByKey } from './route-cache.js';
|
||||||
|
import * as AstroErrorData from '../errors/errors-data.js';
|
||||||
|
|
||||||
interface GetParamsAndPropsOptions {
|
interface GetParamsAndPropsOptions {
|
||||||
mod: ComponentInstance;
|
mod: ComponentInstance;
|
||||||
|
|
|
@ -11,8 +11,9 @@ import { renderSlotToString, type ComponentSlots } from '../../runtime/server/in
|
||||||
import { renderJSX } from '../../runtime/server/jsx.js';
|
import { renderJSX } from '../../runtime/server/jsx.js';
|
||||||
import { chunkToString } from '../../runtime/server/render/index.js';
|
import { chunkToString } from '../../runtime/server/render/index.js';
|
||||||
import { AstroCookies } from '../cookies/index.js';
|
import { AstroCookies } from '../cookies/index.js';
|
||||||
import { AstroError, AstroErrorData } from '../errors/index.js';
|
import { AstroError } from '../errors/index.js';
|
||||||
import { warn, type LogOptions } from '../logger/core.js';
|
import { warn, type LogOptions } from '../logger/core.js';
|
||||||
|
import * as AstroErrorData from '../errors/errors-data.js';
|
||||||
|
|
||||||
const clientAddressSymbol = Symbol.for('astro.clientAddress');
|
const clientAddressSymbol = Symbol.for('astro.clientAddress');
|
||||||
const responseSentSymbol = Symbol.for('astro.responseSent');
|
const responseSentSymbol = Symbol.for('astro.responseSent');
|
||||||
|
|
|
@ -7,9 +7,9 @@ import type {
|
||||||
RouteData,
|
RouteData,
|
||||||
RuntimeMode,
|
RuntimeMode,
|
||||||
} from '../../@types/astro';
|
} from '../../@types/astro';
|
||||||
import { AstroError, AstroErrorData } from '../errors/index.js';
|
import { AstroError } from '../errors/index.js';
|
||||||
import { debug, warn, type LogOptions } from '../logger/core.js';
|
import { debug, warn, type LogOptions } from '../logger/core.js';
|
||||||
|
import * as AstroErrorData from '../errors/errors-data.js';
|
||||||
import { stringifyParams } from '../routing/params.js';
|
import { stringifyParams } from '../routing/params.js';
|
||||||
import { validateDynamicRouteModule, validateGetStaticPathsResult } from '../routing/validation.js';
|
import { validateDynamicRouteModule, validateGetStaticPathsResult } from '../routing/validation.js';
|
||||||
import { generatePaginateFunction } from './paginate.js';
|
import { generatePaginateFunction } from './paginate.js';
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
import type { ComponentInstance, GetStaticPathsResult, RouteData } from '../../@types/astro';
|
import type { ComponentInstance, GetStaticPathsResult, RouteData } from '../../@types/astro';
|
||||||
import { AstroError, AstroErrorData } from '../errors/index.js';
|
import { AstroError } from '../errors/index.js';
|
||||||
import type { LogOptions } from '../logger/core';
|
import type { LogOptions } from '../logger/core';
|
||||||
import { warn } from '../logger/core.js';
|
import { warn } from '../logger/core.js';
|
||||||
|
import * as AstroErrorData from '../errors/errors-data.js';
|
||||||
|
|
||||||
const VALID_PARAM_TYPES = ['string', 'number', 'undefined'];
|
const VALID_PARAM_TYPES = ['string', 'number', 'undefined'];
|
||||||
|
|
||||||
|
|
|
@ -15,8 +15,9 @@ import { resolveConfig } from '../config/config.js';
|
||||||
import { createNodeLogging } from '../config/logging.js';
|
import { createNodeLogging } from '../config/logging.js';
|
||||||
import { createSettings } from '../config/settings.js';
|
import { createSettings } from '../config/settings.js';
|
||||||
import { createVite } from '../create-vite.js';
|
import { createVite } from '../create-vite.js';
|
||||||
import { AstroError, AstroErrorData, createSafeError, isAstroError } from '../errors/index.js';
|
import { AstroError, createSafeError, isAstroError } from '../errors/index.js';
|
||||||
import { info, type LogOptions } from '../logger/core.js';
|
import { info, type LogOptions } from '../logger/core.js';
|
||||||
|
import * as AstroErrorData from '../errors/errors-data.js';
|
||||||
|
|
||||||
export type ProcessExit = 0 | 1;
|
export type ProcessExit = 0 | 1;
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import type { ZodError } from 'zod';
|
import type { ZodError } from 'zod';
|
||||||
import type { ErrorData } from '../core/errors/errors-data.js';
|
import type { ErrorData } from '../core/errors/errors-data.js';
|
||||||
import { AstroError, AstroErrorData, type ErrorWithMetadata } from '../core/errors/index.js';
|
import { AstroError, type ErrorWithMetadata } from '../core/errors/index.js';
|
||||||
|
import * as AstroErrorData from '../core/errors/errors-data.js';
|
||||||
|
|
||||||
const EVENT_ERROR = 'ASTRO_CLI_ERROR';
|
const EVENT_ERROR = 'ASTRO_CLI_ERROR';
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
import type { PluginObj } from '@babel/core';
|
import type { PluginObj } from '@babel/core';
|
||||||
import * as t from '@babel/types';
|
import * as t from '@babel/types';
|
||||||
import { AstroErrorData } from '../core/errors/errors-data.js';
|
|
||||||
import { AstroError } from '../core/errors/errors.js';
|
import { AstroError } from '../core/errors/errors.js';
|
||||||
import { resolvePath } from '../core/util.js';
|
import { resolvePath } from '../core/util.js';
|
||||||
import type { PluginMetadata } from '../vite-plugin-astro/types';
|
import type { PluginMetadata } from '../vite-plugin-astro/types';
|
||||||
|
import * as AstroErrorData from '../core/errors/errors-data.js';
|
||||||
|
|
||||||
const ClientOnlyPlaceholder = 'astro-client-only';
|
const ClientOnlyPlaceholder = 'astro-client-only';
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import type { PropagationHint } from '../../@types/astro';
|
import type { PropagationHint } from '../../@types/astro';
|
||||||
import { AstroError, AstroErrorData } from '../../core/errors/index.js';
|
import { AstroError } from '../../core/errors/index.js';
|
||||||
import type { AstroComponentFactory } from './render/index.js';
|
import type { AstroComponentFactory } from './render/index.js';
|
||||||
|
import * as AstroErrorData from '../../core/errors/errors-data.js';
|
||||||
|
|
||||||
function validateArgs(args: unknown[]): args is Parameters<AstroComponentFactory> {
|
function validateArgs(args: unknown[]): args is Parameters<AstroComponentFactory> {
|
||||||
if (args.length !== 3) return false;
|
if (args.length !== 3) return false;
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import type { AstroGlobalPartial } from '../../@types/astro';
|
import type { AstroGlobalPartial } from '../../@types/astro';
|
||||||
import { ASTRO_VERSION } from '../../core/constants.js';
|
import { ASTRO_VERSION } from '../../core/constants.js';
|
||||||
import { AstroError, AstroErrorData } from '../../core/errors/index.js';
|
import { AstroError } from '../../core/errors/index.js';
|
||||||
|
import * as AstroErrorData from '../../core/errors/errors-data.js';
|
||||||
|
|
||||||
/** Create the Astro.glob() runtime function. */
|
/** Create the Astro.glob() runtime function. */
|
||||||
function createAstroGlobFn() {
|
function createAstroGlobFn() {
|
||||||
|
|
|
@ -4,10 +4,11 @@ import type {
|
||||||
SSRLoadedRenderer,
|
SSRLoadedRenderer,
|
||||||
SSRResult,
|
SSRResult,
|
||||||
} from '../../@types/astro';
|
} from '../../@types/astro';
|
||||||
import { AstroError, AstroErrorData } from '../../core/errors/index.js';
|
import { AstroError } from '../../core/errors/index.js';
|
||||||
import { escapeHTML } from './escape.js';
|
import { escapeHTML } from './escape.js';
|
||||||
import { serializeProps } from './serialize.js';
|
import { serializeProps } from './serialize.js';
|
||||||
import { serializeListValue } from './util.js';
|
import { serializeListValue } from './util.js';
|
||||||
|
import * as AstroErrorData from '../../core/errors/errors-data.js';
|
||||||
|
|
||||||
export interface HydrationMetadata {
|
export interface HydrationMetadata {
|
||||||
directive: string;
|
directive: string;
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import type { RouteData, SSRResult } from '../../../../@types/astro';
|
import type { RouteData, SSRResult } from '../../../../@types/astro';
|
||||||
import { AstroError, AstroErrorData } from '../../../../core/errors/index.js';
|
import { AstroError } from '../../../../core/errors/index.js';
|
||||||
|
import * as AstroErrorData from '../../../../core/errors/errors-data.js';
|
||||||
import { chunkToByteArray, chunkToString, encoder, type RenderDestination } from '../common.js';
|
import { chunkToByteArray, chunkToString, encoder, type RenderDestination } from '../common.js';
|
||||||
import type { AstroComponentFactory } from './factory.js';
|
import type { AstroComponentFactory } from './factory.js';
|
||||||
import { isHeadAndContent } from './head-and-content.js';
|
import { isHeadAndContent } from './head-and-content.js';
|
||||||
|
|
|
@ -5,8 +5,8 @@ import type {
|
||||||
SSRResult,
|
SSRResult,
|
||||||
} from '../../../@types/astro';
|
} from '../../../@types/astro';
|
||||||
import type { RenderInstruction } from './types.js';
|
import type { RenderInstruction } from './types.js';
|
||||||
|
import * as AstroErrorData from '../../../core/errors/errors-data.js';
|
||||||
import { AstroError, AstroErrorData } from '../../../core/errors/index.js';
|
import { AstroError } from '../../../core/errors/index.js';
|
||||||
import { HTMLBytes, markHTMLString } from '../escape.js';
|
import { HTMLBytes, markHTMLString } from '../escape.js';
|
||||||
import { extractDirectives, generateHydrateScript } from '../hydration.js';
|
import { extractDirectives, generateHydrateScript } from '../hydration.js';
|
||||||
import { serializeProps } from '../serialize.js';
|
import { serializeProps } from '../serialize.js';
|
||||||
|
|
|
@ -18,6 +18,7 @@ export default function astroTransitions({ config }: { config: AstroConfig }): v
|
||||||
if (id === resolvedVirtualModuleId) {
|
if (id === resolvedVirtualModuleId) {
|
||||||
if (!config.experimental.viewTransitions) {
|
if (!config.experimental.viewTransitions) {
|
||||||
throw new AstroError({
|
throw new AstroError({
|
||||||
|
name: 'TransitionError',
|
||||||
title: 'Experimental View Transitions not enabled',
|
title: 'Experimental View Transitions not enabled',
|
||||||
message: `View Transitions support is experimental. To enable update your config to include:
|
message: `View Transitions support is experimental. To enable update your config to include:
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,8 @@ import type {
|
||||||
SSRManifest,
|
SSRManifest,
|
||||||
} from '../@types/astro';
|
} from '../@types/astro';
|
||||||
import { attachToResponse } from '../core/cookies/index.js';
|
import { attachToResponse } from '../core/cookies/index.js';
|
||||||
import { AstroErrorData, isAstroError } from '../core/errors/index.js';
|
import { isAstroError } from '../core/errors/index.js';
|
||||||
|
import * as AstroErrorData from '../core/errors/errors-data.js';
|
||||||
import { warn } from '../core/logger/core.js';
|
import { warn } from '../core/logger/core.js';
|
||||||
import { loadMiddleware } from '../core/middleware/loadMiddleware.js';
|
import { loadMiddleware } from '../core/middleware/loadMiddleware.js';
|
||||||
import { isEndpointResult } from '../core/render/core.js';
|
import { isEndpointResult } from '../core/render/core.js';
|
||||||
|
|
|
@ -10,7 +10,8 @@ import { fileURLToPath } from 'node:url';
|
||||||
import type { Plugin } from 'vite';
|
import type { Plugin } from 'vite';
|
||||||
import { normalizePath } from 'vite';
|
import { normalizePath } from 'vite';
|
||||||
import type { AstroSettings } from '../@types/astro';
|
import type { AstroSettings } from '../@types/astro';
|
||||||
import { AstroError, AstroErrorData, MarkdownError } from '../core/errors/index.js';
|
import { AstroError, MarkdownError } from '../core/errors/index.js';
|
||||||
|
import * as AstroErrorData from '../core/errors/errors-data.js';
|
||||||
import type { LogOptions } from '../core/logger/core.js';
|
import type { LogOptions } from '../core/logger/core.js';
|
||||||
import { warn } from '../core/logger/core.js';
|
import { warn } from '../core/logger/core.js';
|
||||||
import { isMarkdownFile, rootRelativePath } from '../core/util.js';
|
import { isMarkdownFile, rootRelativePath } from '../core/util.js';
|
||||||
|
@ -27,6 +28,7 @@ function safeMatter(source: string, id: string) {
|
||||||
return matter(source);
|
return matter(source);
|
||||||
} catch (err: any) {
|
} catch (err: any) {
|
||||||
const markdownError = new MarkdownError({
|
const markdownError = new MarkdownError({
|
||||||
|
name: 'MarkdownError',
|
||||||
message: err.message,
|
message: err.message,
|
||||||
stack: err.stack,
|
stack: err.stack,
|
||||||
location: {
|
location: {
|
||||||
|
@ -61,6 +63,10 @@ const astroErrorModulePath = normalizePath(
|
||||||
fileURLToPath(new URL('../core/errors/index.js', import.meta.url))
|
fileURLToPath(new URL('../core/errors/index.js', import.meta.url))
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const astroErrorDataModulePath = normalizePath(
|
||||||
|
fileURLToPath(new URL('../core/errors/errors-data.js', import.meta.url))
|
||||||
|
);
|
||||||
|
|
||||||
export default function markdown({ settings, logging }: AstroPluginOptions): Plugin {
|
export default function markdown({ settings, logging }: AstroPluginOptions): Plugin {
|
||||||
return {
|
return {
|
||||||
enforce: 'pre',
|
enforce: 'pre',
|
||||||
|
@ -116,7 +122,8 @@ export default function markdown({ settings, logging }: AstroPluginOptions): Plu
|
||||||
const code = escapeViteEnvReferences(`
|
const code = escapeViteEnvReferences(`
|
||||||
import { Fragment, jsx as h } from ${JSON.stringify(astroJsxRuntimeModulePath)};
|
import { Fragment, jsx as h } from ${JSON.stringify(astroJsxRuntimeModulePath)};
|
||||||
import { spreadAttributes } from ${JSON.stringify(astroServerRuntimeModulePath)};
|
import { spreadAttributes } from ${JSON.stringify(astroServerRuntimeModulePath)};
|
||||||
import { AstroError, AstroErrorData } from ${JSON.stringify(astroErrorModulePath)};
|
import { AstroError } from ${JSON.stringify(astroErrorModulePath)};
|
||||||
|
import { MarkdownImageNotFound } from ${JSON.stringify(astroErrorDataModulePath)};
|
||||||
|
|
||||||
${layout ? `import Layout from ${JSON.stringify(layout)};` : ''}
|
${layout ? `import Layout from ${JSON.stringify(layout)};` : ''}
|
||||||
${settings.config.experimental.assets ? 'import { getImage } from "astro:assets";' : ''}
|
${settings.config.experimental.assets ? 'import { getImage } from "astro:assets";' : ''}
|
||||||
|
@ -133,8 +140,8 @@ export default function markdown({ settings, logging }: AstroPluginOptions): Plu
|
||||||
async function getImageSafely(imageSrc, imagePath, resolvedImagePath) {
|
async function getImageSafely(imageSrc, imagePath, resolvedImagePath) {
|
||||||
if (!imageSrc) {
|
if (!imageSrc) {
|
||||||
throw new AstroError({
|
throw new AstroError({
|
||||||
...AstroErrorData.MarkdownImageNotFound,
|
...MarkdownImageNotFound,
|
||||||
message: AstroErrorData.MarkdownImageNotFound.message(
|
message: MarkdownImageNotFound.message(
|
||||||
imagePath,
|
imagePath,
|
||||||
resolvedImagePath
|
resolvedImagePath
|
||||||
),
|
),
|
||||||
|
|
|
@ -2,7 +2,8 @@ import type { AstroSettings } from '../@types/astro.js';
|
||||||
import type { PageOptions } from '../vite-plugin-astro/types.js';
|
import type { PageOptions } from '../vite-plugin-astro/types.js';
|
||||||
|
|
||||||
import * as eslexer from 'es-module-lexer';
|
import * as eslexer from 'es-module-lexer';
|
||||||
import { AstroError, AstroErrorData } from '../core/errors/index.js';
|
import { AstroError } from '../core/errors/index.js';
|
||||||
|
import * as AstroErrorData from '../core/errors/errors-data.js';
|
||||||
|
|
||||||
const BOOLEAN_EXPORTS = new Set(['prerender']);
|
const BOOLEAN_EXPORTS = new Set(['prerender']);
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { expect } from 'chai';
|
import { expect } from 'chai';
|
||||||
import { AstroErrorData } from '../dist/core/errors/errors-data.js';
|
import * as AstroErrorData from '../dist/core/errors/errors-data.js';
|
||||||
import { AstroError } from '../dist/core/errors/errors.js';
|
import { AstroError } from '../dist/core/errors/errors.js';
|
||||||
import * as events from '../dist/events/index.js';
|
import * as events from '../dist/events/index.js';
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue