-
-
Notifications
You must be signed in to change notification settings - Fork 639
/
index.ts
52 lines (46 loc) · 1.44 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/*
* @adonisjs/core
*
* (c) AdonisJS
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
import { errors as aceErrors } from '@adonisjs/ace'
import { errors as envErrors } from '@adonisjs/env'
import { errors as appErrors } from '@adonisjs/application'
import { errors as encryptionErrors } from '@adonisjs/encryption'
import { errors as httpServerErrors } from '@adonisjs/http-server'
export { stubsRoot } from './stubs/main.js'
export { inject } from './modules/container.js'
export { Ignitor } from './src/ignitor/main.js'
export { configProvider } from './src/config_provider.js'
/**
* Aggregated errors from all modules.
*/
export const errors: typeof encryptionErrors &
typeof httpServerErrors &
typeof appErrors &
typeof aceErrors &
typeof envErrors = {
...encryptionErrors,
...httpServerErrors,
...appErrors,
...aceErrors,
...envErrors,
}
/**
* Pretty prints an error with colorful output using
* Youch terminal
*/
export async function prettyPrintError(error: any) {
if (error && typeof error === 'object' && error.code === 'E_DUMP_DIE_EXCEPTION') {
console.error(error)
return
}
// @ts-expect-error
const { default: youchTerminal } = await import('youch-terminal')
const { default: Youch } = await import('youch')
const youch = new Youch(error, {})
console.error(youchTerminal(await youch.toJSON(), { displayShortPath: true }))
}