Skip to content

Commit e6fdfa6

Browse files
committed
Improve error message context
1 parent d09f80a commit e6fdfa6

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/index.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -195,30 +195,30 @@ function laravelVersion(): string {
195195
*/
196196
function resolvePluginConfig(config: string|string[]|PluginConfig): Required<PluginConfig> {
197197
if (typeof config === 'undefined') {
198-
throw new Error('Missing configuration')
198+
throw new Error('laravel-vite-plugin: missing configuration.')
199199
}
200200

201201
if (typeof config === 'string' || Array.isArray(config)) {
202202
config = { input: config, ssr: config }
203203
}
204204

205205
if (typeof config.input === 'undefined') {
206-
throw new Error('Missing configuration for key: input')
206+
throw new Error('laravel-vite-plugin: missing configuration for "input".')
207207
}
208208

209209
if (typeof config.publicDirectory === 'string') {
210210
config.publicDirectory = config.publicDirectory.trim().replace(/^\/+/, '')
211211

212212
if (config.publicDirectory === '') {
213-
throw new Error('publicDirectory must be a subdirectory. E.g. \'public\'.')
213+
throw new Error('laravel-vite-plugin: publicDirectory must be a subdirectory. E.g. \'public\'.')
214214
}
215215
}
216216

217217
if (typeof config.buildDirectory === 'string') {
218218
config.buildDirectory = config.buildDirectory.trim().replace(/^\/+/, '').replace(/\/+$/, '')
219219

220220
if (config.buildDirectory === '') {
221-
throw new Error('buildDirectory must be a subdirectory. E.g. \'build\'.')
221+
throw new Error('laravel-vite-plugin: buildDirectory must be a subdirectory. E.g. \'build\'.')
222222
}
223223
}
224224

tests/index.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ describe('laravel-vite-plugin', () => {
1111
/* eslint-disable-next-line @typescript-eslint/ban-ts-comment */
1212
/* @ts-ignore */
1313
expect(() => laravel())
14-
.toThrowError('Missing configuration');
14+
.toThrowError('laravel-vite-plugin: missing configuration.');
1515

1616
/* eslint-disable-next-line @typescript-eslint/ban-ts-comment */
1717
/* @ts-ignore */
1818
expect(() => laravel({}))
19-
.toThrowError('Missing configuration for key: input');
19+
.toThrowError('laravel-vite-plugin: missing configuration for "input".');
2020
})
2121

2222
it('accepts a single input', () => {

0 commit comments

Comments
 (0)