bullseye: Log exceptions inside targets
Benefits
- Less scrolling to see the last target which failed (as mentioned below)
- Smaller stack traces, since the exception is being logged further down the stack
- When running with
--parallel
, all exception details are shown.
Before
After
Original text by @Mpdreamz
Currently exceptions bubble out of `RunTargets(Async)()`C:\Projects\elastic\net-master>build.cmd walkdog
Bullseye: Starting... (walkdog)
Bullseye/walkdog: Starting...
Bullseye/walkdog: Failed! boom! (8.34 ms)
Bullseye: Failed! (walkdog) (23.4 ms)
Unhandled Exception: System.Exception: boom!
at targets.WalkDogTarget.Exec() in C:\Projects\elastic\net-master\build\targets\Progra
m.cs:line 40
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, Co
ntextCallback callback, Object state)
--- End of stack trace from previous location where exception was thrown ---
at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot)
--- End of stack trace from previous location where exception was thrown ---
at Bullseye.Internal.ActionTarget.RunAsync(Boolean dryRun, Boolean parallel, Logger lo
g) in C:\projects\bullseye\Bullseye\Internal\ActionTarget.cs:line 25
at Bullseye.Internal.ActionTarget.RunAsync(Boolean dryRun, Boolean parallel, Logger lo
g) in C:\projects\bullseye\Bullseye\Internal\ActionTarget.cs:line 31
at Bullseye.Internal.TargetCollection.RunAsync(String name, List`1 explicitTargets, Bo
olean skipDependencies, Boolean dryRun, Boolean parallel, ConcurrentDictionary`2 targetsR
an, Logger log, Stack`1 targets) in C:\projects\bullseye\Bullseye\Internal\TargetCollecti
on.cs:line 83
at Bullseye.Internal.TargetCollection.RunAsync(List`1 names, Boolean skipDependencies,
Boolean dryRun, Boolean parallel, Logger log) in C:\projects\bullseye\Bullseye\Internal\
TargetCollection.cs:line 38
at Bullseye.Internal.TargetCollection.RunAsync(List`1 names, Boolean skipDependencies,
Boolean dryRun, Boolean parallel, Logger log) in C:\projects\bullseye\Bullseye\Internal\
TargetCollection.cs:line 47
at Bullseye.Internal.TargetCollectionExtensions.RunAsync(TargetCollection targets, Lis
t`1 args, IConsole console) in C:\projects\bullseye\Bullseye\Internal\TargetCollectionExt
ensions.cs:line 171
at targets.Program.Main(String[] args) in C:\Projects\elastic\net-master\build\targets
\Program.cs:line 26
at targets.Program.<Main>(String[] args)
C:\Projects\elastic\net-master>
If the order were different:
C:\Projects\elastic\net-master>build.cmd walkdog
Bullseye: Starting... (walkdog)
Bullseye/walkdog: Starting...
Unhandled Exception: System.Exception: boom!
at targets.WalkDogTarget.Exec() in C:\Projects\elastic\net-master\build\targets\Progra
m.cs:line 40
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, Co
ntextCallback callback, Object state)
--- End of stack trace from previous location where exception was thrown ---
at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot)
--- End of stack trace from previous location where exception was thrown ---
at Bullseye.Internal.ActionTarget.RunAsync(Boolean dryRun, Boolean parallel, Logger lo
g) in C:\projects\bullseye\Bullseye\Internal\ActionTarget.cs:line 25
at Bullseye.Internal.ActionTarget.RunAsync(Boolean dryRun, Boolean parallel, Logger lo
g) in C:\projects\bullseye\Bullseye\Internal\ActionTarget.cs:line 31
at Bullseye.Internal.TargetCollection.RunAsync(String name, List`1 explicitTargets, Bo
olean skipDependencies, Boolean dryRun, Boolean parallel, ConcurrentDictionary`2 targetsR
an, Logger log, Stack`1 targets) in C:\projects\bullseye\Bullseye\Internal\TargetCollecti
on.cs:line 83
at Bullseye.Internal.TargetCollection.RunAsync(List`1 names, Boolean skipDependencies,
Boolean dryRun, Boolean parallel, Logger log) in C:\projects\bullseye\Bullseye\Internal\
TargetCollection.cs:line 38
at Bullseye.Internal.TargetCollection.RunAsync(List`1 names, Boolean skipDependencies,
Boolean dryRun, Boolean parallel, Logger log) in C:\projects\bullseye\Bullseye\Internal\
TargetCollection.cs:line 47
at Bullseye.Internal.TargetCollectionExtensions.RunAsync(TargetCollection targets, Lis
t`1 args, IConsole console) in C:\projects\bullseye\Bullseye\Internal\TargetCollectionExt
ensions.cs:line 171
at targets.Program.Main(String[] args) in C:\Projects\elastic\net-master\build\targets
\Program.cs:line 26
at targets.Program.<Main>(String[] args)
Bullseye/walkdog: Failed! boom! (8.34 ms)
Bullseye: Failed! (walkdog) (23.4 ms)
C:\Projects\elastic\net-master>
The last lines would always indicate the faulty target and a user does not have to scroll their terminal.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 16 (9 by maintainers)
Maybe what I want is a way to print a summary more then anything else:
e.g from a FAKE build script:
I really like having this be the last thing printed consistently as I often keep an eye out on task running times.