Skip to content

Commit c01f36c

Browse files
feat: improve error messages
1 parent 6a6cecf commit c01f36c

File tree

6 files changed

+22
-18
lines changed

6 files changed

+22
-18
lines changed

docs/config/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ interface ModuleOptions {
3131
/**
3232
* Kirby KQL API route path
3333
*
34-
* @default 'api/query' for `basic` authentication
35-
* @default 'api/kql' for `bearer` authentication
34+
* @default 'api/query' // for `basic` authentication
35+
* @default 'api/kql' // for `bearer` authentication
3636
*/
3737
prefix?: string
3838

docs/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@
88
"serve": "vitepress serve"
99
},
1010
"devDependencies": {
11-
"vitepress": "^1.0.0-rc.43"
11+
"vitepress": "^1.0.0-rc.44"
1212
}
1313
}

playground/app.vue

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
1-
<template>
2-
<Head>
3-
<Title>nuxt-kql</Title>
4-
<Link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@exampledev/new.css@1.1.2/new.min.css" />
5-
</Head>
1+
<script setup lang="ts">
2+
useServerHead({
3+
title: 'nuxt-kql',
4+
link: [
5+
{ rel: 'stylesheet', href: 'https://cdn.jsdelivr.net/npm/@exampledev/new.css@1.1.2/new.min.css' },
6+
],
7+
})
8+
</script>
69

10+
<template>
711
<NuxtLayout>
812
<NuxtPage />
913
</NuxtLayout>

src/module.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ export interface ModuleOptions {
1717
/**
1818
* Kirby KQL API route path
1919
*
20-
* @default 'api/query' for `basic` authentication
21-
* @default 'api/kql' for `bearer` authentication
20+
* @default 'api/query' // for `basic` authentication
21+
* @default 'api/kql' // for `bearer` authentication
2222
*/
2323
prefix?: string
2424

@@ -155,14 +155,14 @@ export default defineNuxtModule<ModuleOptions>({
155155

156156
// Make sure Kirby URL and KQL endpoint are set
157157
if (!options.url)
158-
logger.error('Missing `KIRBY_BASE_URL` in `.env`')
158+
logger.error('Missing `KIRBY_BASE_URL` environment variable')
159159

160160
// Make sure authentication credentials are set
161161
if (options.auth === 'basic' && (!options.credentials || !options.credentials.username || !options.credentials.password))
162-
logger.error('Missing `KIRBY_API_USERNAME` and `KIRBY_API_PASSWORD` in `.env` for basic authentication')
162+
logger.error('Missing `KIRBY_API_USERNAME` and `KIRBY_API_PASSWORD` environment variable for basic authentication')
163163

164164
if (options.auth === 'bearer' && !options.token)
165-
logger.error('Missing `KIRBY_API_TOKEN` in `.env` for bearer authentication')
165+
logger.error('Missing `KIRBY_API_TOKEN` environment variable for bearer authentication')
166166

167167
if (!options.prefix) {
168168
if (options.auth === 'basic')

src/prefetch.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export async function prefetchQueries(
1919

2020
if (language && !query.query) {
2121
logger.error(
22-
`Couldn't prefetch ${key} KQL query: \`language\` option requires a \`query\``,
22+
`Failed to prefetch ${key} multi-language KQL query: \`query\` is required`,
2323
)
2424
continue
2525
}
@@ -38,8 +38,8 @@ export async function prefetchQueries(
3838
}),
3939
)
4040
}
41-
catch (e) {
42-
logger.error(`Couldn't prefetch ${key} KQL query:`, e)
41+
catch (error) {
42+
logger.error(`Failed to prefetch ${key} KQL query:`, error)
4343
}
4444
}
4545

src/runtime/server/handler.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ async function fetcher({
4242

4343
return result
4444
}
45-
catch (err) {
45+
catch (error) {
4646
if (kql.server.verboseErrors) {
4747
if (isQueryRequest)
4848
consola.error('Failed to execute KQL query:', query)
@@ -54,7 +54,7 @@ async function fetcher({
5454
statusMessage: isQueryRequest
5555
? 'Failed to execute KQL query'
5656
: `Failed to fetch "${path}"`,
57-
data: (err as NuxtError).message,
57+
data: (error as NuxtError).message,
5858
})
5959
}
6060
}

0 commit comments

Comments
 (0)