Skip to content

Commit b42f91a

Browse files
committed
Refactoring
1 parent cfc8e86 commit b42f91a

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

src/message.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ const defaultGetMessage = function({
3737
}
3838

3939
const uncaughtException = function({ error }) {
40-
return `an exception was thrown but not caught
40+
return ` (an exception was thrown but not caught)
4141
${serialize(error)}`
4242
}
4343

@@ -49,12 +49,12 @@ ${codeMessage}${detailMessage}${serialize(error)}`
4949
}
5050

5151
const unhandledRejection = function({ promiseValue }) {
52-
return `a promise was rejected but not handled
52+
return ` (a promise was rejected but not handled)
5353
${serialize(promiseValue)}`
5454
}
5555

5656
const rejectionHandled = function({ promiseValue }) {
57-
return `a promise was rejected and handled too late
57+
return ` (a promise was rejected and handled too late)
5858
${serialize(promiseValue)}`
5959
}
6060

@@ -67,7 +67,7 @@ const multipleResolves = function({
6767
const again = promiseState === secondPromiseState ? ' again' : ''
6868
const state = again ? promiseState : 'resolve/rejected'
6969

70-
return `a promise was ${state} multiple times
70+
return ` (a promise was ${state} multiple times)
7171
Initially ${promiseState} with: ${serialize(promiseValue)}
7272
Then ${secondPromiseState}${again} with: ${serialize(secondPromiseValue)}`
7373
}

src/prettify.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,13 @@ const prettify = function({
2121
}) {
2222
const [explanation, firstLine, ...lines] = message.split('\n')
2323

24-
// `warning` events do not have an `explanation`
25-
const explanationA =
26-
explanation === '' ? '' : ` ${italic(`(${explanation})`)}`
27-
2824
// Add color, sign and `eventName` to first message line, and concatenate
2925
// `firstLine`
3026
const { COLOR, SIGN } = LEVELS[level]
3127
const header = colors[COLOR](
32-
`${inverse(bold(` ${SIGN} ${eventName}${explanationA} `))} ${firstLine}`,
28+
`${inverse(
29+
bold(` ${SIGN} ${eventName}${italic(explanation)} `),
30+
)} ${firstLine}`,
3331
)
3432

3533
// Add gray color and indentation to other lines.

0 commit comments

Comments
 (0)