aboutsummaryrefslogtreecommitdiff
path: root/packages/create-astro/src
diff options
context:
space:
mode:
Diffstat (limited to 'packages/create-astro/src')
-rw-r--r--packages/create-astro/src/actions/template.ts22
1 files changed, 18 insertions, 4 deletions
diff --git a/packages/create-astro/src/actions/template.ts b/packages/create-astro/src/actions/template.ts
index 3afd5f3cf..5169c63e3 100644
--- a/packages/create-astro/src/actions/template.ts
+++ b/packages/create-astro/src/actions/template.ts
@@ -83,7 +83,6 @@ export function getTemplateTarget(tmpl: string, ref = 'latest') {
export default async function copyTemplate(tmpl: string, ctx: Context) {
const templateTarget = getTemplateTarget(tmpl, ctx.ref);
-
// Copy
if (!ctx.dryRun) {
try {
@@ -104,11 +103,26 @@ export default async function copyTemplate(tmpl: string, ctx: Context) {
}
}
- if (err.message.includes('404')) {
+ if (err.message?.includes('404')) {
throw new Error(`Template ${color.reset(tmpl)} ${color.dim('does not exist!')}`);
- } else {
- throw new Error(err.message);
}
+
+ if (err.message) {
+ error('error', err.message);
+ }
+ try {
+ // The underlying error is often buried deep in the `cause` property
+ // This is in a try/catch block in case of weirdnesses in accessing the `cause` property
+ if ('cause' in err) {
+ // This is probably included in err.message, but we can log it just in case it has extra info
+ error('error', err.cause);
+ if ('cause' in err.cause) {
+ // Hopefully the actual fetch error message
+ error('error', err.cause?.cause);
+ }
+ }
+ } catch {}
+ throw new Error(`Unable to download template ${color.reset(tmpl)}`);
}
// It's possible the repo exists (ex. `withastro/astro`),