Skip to content

Commit

Permalink
Added a dispatch catch
Browse files Browse the repository at this point in the history
  • Loading branch information
analogrelay committed Jan 21, 2014
1 parent c49d518 commit 14a16ce
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/Services/NuCmd/Commands/Work/GetCommand.cs
Expand Up @@ -72,7 +72,8 @@ private async Task GetByCriteria(InvocationListCriteria criteria)
i.Id,
QueuedAt = i.QueuedAt.LocalDateTime,
UpdatedAt = i.UpdatedAt.LocalDateTime,
CompletedAt = i.CompletedAt.HasValue ? i.CompletedAt.Value.LocalDateTime : (DateTimeOffset?)null
CompletedAt = i.CompletedAt.HasValue ? i.CompletedAt.Value.LocalDateTime : (DateTimeOffset?)null,
i.LastUpdatedBy
});
}
}
Expand Down
Expand Up @@ -106,7 +106,24 @@ public virtual async Task Run(CancellationToken cancelToken)
{
Status = RunnerStatus.Dispatching;
Interlocked.Exchange(ref _currentInvocationId, invocation.Id.ToByteArray());
await Dispatch(invocation, cancelToken);

Exception dispatchError = null;
try
{
await Dispatch(invocation, cancelToken);
}
catch (Exception ex)
{
dispatchError = ex;
}
if (dispatchError != null)
{
await Queue.Complete(
invocation,
ExecutionResult.Crashed,
dispatchError.ToString(),
null);
}
Interlocked.Exchange(ref _currentInvocationId, Guid.Empty.ToByteArray());
Status = RunnerStatus.Working;
}
Expand Down

0 comments on commit 14a16ce

Please sign in to comment.