Skip to content

Commit 71f01af

Browse files
committed
simplify
1 parent afaa278 commit 71f01af

File tree

4 files changed

+9
-10
lines changed

4 files changed

+9
-10
lines changed

packages/astro/src/content/utils.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,7 @@ export async function getEntrySlug({
492492
contents = await fs.promises.readFile(fileUrl, 'utf-8');
493493
} catch (e) {
494494
// File contents should exist. Raise unexpected error as "unknown" if not.
495-
throw new AstroError(AstroErrorData.UnknownContentCollectionError, undefined, { cause: e });
495+
throw new AstroError(AstroErrorData.UnknownContentCollectionError, { cause: e });
496496
}
497497
const { slug: frontmatterSlug } = await contentEntryType.getEntryInfo({
498498
fileUrl,

packages/astro/src/core/errors/errors.ts

+7-7
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ export class AstroError extends Error {
3838

3939
type: ErrorTypes = 'AstroError';
4040

41-
constructor(props: ErrorProperties, ...params: Parameters<ErrorConstructor>) {
42-
super(...params);
43-
41+
constructor(props: ErrorProperties, options?: ErrorOptions) {
4442
const { name, title, message, stack, location, hint, frame } = props;
43+
super(message, options);
44+
4545
this.title = title;
4646
this.name = name;
4747

@@ -81,8 +81,8 @@ export class AstroError extends Error {
8181
export class CompilerError extends AstroError {
8282
type: ErrorTypes = 'CompilerError';
8383

84-
constructor(props: ErrorProperties, ...params: any) {
85-
super(props, ...params);
84+
constructor(props: ErrorProperties, options?: ErrorOptions) {
85+
super(props, options);
8686
}
8787

8888
static is(err: unknown): err is CompilerError {
@@ -120,8 +120,8 @@ export class AggregateError extends AstroError {
120120

121121
// Despite being a collection of errors, AggregateError still needs to have a main error attached to it
122122
// This is because Vite expects every thrown errors handled during HMR to be, well, Error and have a message
123-
constructor(props: ErrorProperties & { errors: AstroError[] }, ...params: any) {
124-
super(props, ...params);
123+
constructor(props: ErrorProperties & { errors: AstroError[] }, options?: ErrorOptions) {
124+
super(props, options);
125125

126126
this.errors = props.errors;
127127
}

packages/astro/src/core/middleware/loadMiddleware.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export async function loadMiddleware(moduleLoader: ModuleLoader) {
1212
try {
1313
return await moduleLoader.import(MIDDLEWARE_MODULE_ID);
1414
} catch (error: any) {
15-
const astroError = new AstroError(MiddlewareCantBeLoaded, undefined, { cause: error });
15+
const astroError = new AstroError(MiddlewareCantBeLoaded, { cause: error });
1616
throw astroError;
1717
}
1818
}

packages/astro/src/core/sync/index.ts

-1
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,6 @@ export async function syncInternal(
131131
...AstroErrorData.GenerateContentTypesError,
132132
message: AstroErrorData.GenerateContentTypesError.message(safeError.message),
133133
},
134-
undefined,
135134
{ cause: e }
136135
);
137136
} finally {

0 commit comments

Comments
 (0)