Skip to content

Commit 7e40798

Browse files
committed
improve markdown-db errors
1 parent 1687534 commit 7e40798

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

packages/markdown-db/src/markdown-db.engine.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -208,21 +208,19 @@ export class MarkdownDb<
208208
const headerData = await new Promise((resolve) =>
209209
resolve(md.getHeaderData(mdText)),
210210
).catch(async (err) => {
211-
throw new Error(t`
212-
Failed to read markdown file header
213-
- File: ${this._cwd.relativePathTo(mdFile)}
214-
- Error:
215-
${err.message as string}
216-
`);
211+
throw new Error(
212+
`Failed to read markdown file header for ${this._cwd.relativePathTo(mdFile)}`,
213+
{ cause: err },
214+
);
217215
});
218216

219217
// Validate the header data
220218
const parsedData = this._configSchema.safeParse(headerData);
221219
if (!parsedData.success)
222-
throw new Error(t`
223-
Failed to parse config for ${mdFile.path}:
224-
${z.prettifyError(parsedData.error)}
225-
`);
220+
throw new Error(
221+
`Failed to parse config for ${this._cwd.relativePathTo(mdFile)}`,
222+
{ cause: parsedData.error },
223+
);
226224

227225
// Compute the entry id
228226
const { name, type } = this.computeEntryId(mdFile);

0 commit comments

Comments
 (0)