Skip to content

Commit

Permalink
Improve error handling in reporters
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky committed Feb 6, 2022
1 parent ec8a9bf commit 222d9a0
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions src/report/contents/get.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import omit from 'omit.js'

import { PluginError } from '../../error/main.js'
import { wrapError } from '../../error/wrap.js'
import { FORMATS } from '../formats/list.js'

// Retrieve reporter's contents by calling all `reporter.report()` then
Expand Down Expand Up @@ -29,12 +31,17 @@ const callReportFunc = async function ({
reporterConfig,
CORE_REPORTER_PROPS,
)
const content = await FORMATS[format].report(reporter, [
result,
reporterSpecificConfig,
startData,
])
return { content, result, format, footerString, output, colors }

try {
const content = await FORMATS[format].report(reporter, [
result,
reporterSpecificConfig,
startData,
])
return { content, result, format, footerString, output, colors }
} catch (error) {
throw wrapError(error, '', PluginError)
}
}

// We only pass reporter-specific properties, not core ones
Expand Down

0 comments on commit 222d9a0

Please sign in to comment.