Skip to content

Commit 241f767

Browse files
committed
feat(exception): paint message and help values in pretiffy
1 parent ee53591 commit 241f767

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+68
-49
lines changed

index.d.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
/**
2+
* @secjs/utils
3+
*
4+
* (c) João Lenon <[email protected]>
5+
*
6+
* For the full copyright and license information, please view the LICENSE
7+
* file that was distributed with this source code.
8+
*/
9+
110
export declare interface ExceptionJSON {
211
code?: string
312
name: string
@@ -115,7 +124,7 @@ export declare class Debug {
115124
export declare class Exception extends Error {
116125
constructor(content?: string, status?: number, code?: string, help?: string)
117126

118-
toJSON(stack: boolean): ExceptionJSON
127+
toJSON(stack?: boolean): ExceptionJSON
119128

120129
prettify(options?: {
121130
prefix?: string

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* @secjs/esm
2+
* @secjs/utils
33
*
44
* (c) João Lenon <[email protected]>
55
*

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@secjs/utils",
3-
"version": "1.8.4",
3+
"version": "1.8.5",
44
"description": "Utils functions and classes for Node.js",
55
"license": "MIT",
66
"author": "João Lenon <[email protected]>",

src/Clean.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* @secjs/esm
2+
* @secjs/utils
33
*
44
* (c) João Lenon <[email protected]>
55
*

src/Config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* @secjs/esm
2+
* @secjs/utils
33
*
44
* (c) João Lenon <[email protected]>
55
*

src/Debug.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* @secjs/esm
2+
* @secjs/utils
33
*
44
* (c) João Lenon <[email protected]>
55
*

src/Exception.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* @secjs/esm
2+
* @secjs/utils
33
*
44
* (c) João Lenon <[email protected]>
55
*
@@ -8,6 +8,7 @@
88
*/
99

1010
import Youch from 'youch'
11+
import chalk from 'chalk'
1112
import changeCase from 'change-case'
1213
import YouchTerminal from 'youch-terminal'
1314

@@ -113,8 +114,16 @@ export class Exception extends Error {
113114
displayMainFrameOnly: false,
114115
})
115116

117+
const message = `${chalk.yellow.bold('MESSAGE')}\n ${this.message}`
118+
const help = ` ${chalk.green.bold('HELP')}\n ${this.help}`
119+
116120
this.name = this.code
117-
this.message = `Message: ${this.message}\n Help: ${this.help}`
121+
122+
if (this.help) {
123+
this.message = `${message}\n\n${help}`
124+
} else {
125+
this.message = `${message}`
126+
}
118127

119128
const jsonResponse = await new Youch(this, {}).toJSON()
120129

src/Exceptions/ConfigNotNormalizedException.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* @secjs/esm
2+
* @secjs/utils
33
*
44
* (c) João Lenon <[email protected]>
55
*

src/Exceptions/InvalidNumberException.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* @secjs/esm
2+
* @secjs/utils
33
*
44
* (c) João Lenon <[email protected]>
55
*

src/Exceptions/InvalidUuidException.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* @secjs/esm
2+
* @secjs/utils
33
*
44
* (c) João Lenon <[email protected]>
55
*

0 commit comments

Comments
 (0)