Skip to content

Commit

Permalink
feat(core): $log property in error thrown by action
Browse files Browse the repository at this point in the history
  • Loading branch information
wdavidw committed Mar 8, 2021
1 parent 0849ca2 commit 6a7d4e8
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 7 deletions.
15 changes: 11 additions & 4 deletions packages/core/lib/plugins/output_logs.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 7 additions & 3 deletions packages/core/src/plugins/output_logs.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ module.exports =
handler: ({action, output}, handler) ->
return handler if action.metadata.raw_output
({action}) ->
output = await handler.apply null, arguments
output.$logs = action.state.logs if is_object_literal output
output
try
output = await handler.apply null, arguments
output.$logs = action.state.logs if is_object_literal output
output
catch err
err.$logs = action.state.logs
throw err
12 changes: 12 additions & 0 deletions packages/core/test/plugins/output/logs.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,15 @@ describe 'plugins.output.logs', ->
$logs.some (log) ->
log.file.should.eql 'logs.coffee'
log.filename.should.eql __filename

it 'return logs in error', ->
nikita ->
try
await @call ({tools: {log}}) ->
log key: 'value'
throw Error 'catchme'
catch err
err.message.should.eql 'catchme'
err.$logs.some (log) ->
log.type is 'text' and log.key is 'value'
.should.be.true()

0 comments on commit 6a7d4e8

Please sign in to comment.