Skip to content

Commit c911a25

Browse files
committed
Handle exceptions in peek command
1 parent 7e762a2 commit c911a25

File tree

1 file changed

+30
-10
lines changed
  • src/InEngine.Core/Queuing/Commands

1 file changed

+30
-10
lines changed

src/InEngine.Core/Queuing/Commands/Peek.cs

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,28 +39,48 @@ public override void Run()
3939
throw new ArgumentException("--to cannot be negative");
4040
if (To < From)
4141
throw new ArgumentException("--from cannot be greater than --to");
42-
42+
4343
if (PendingQueue == false && FailedQueue == false && InProgressQueue == false)
4444
throw new CommandFailedException("Must specify at least one queue to peek in. Use -h to see available options.");
4545
var queue = QueueAdapter.Make(UseSecondaryQueue);
46-
if (PendingQueue) {
47-
PrintMessages(queue.PeekPendingMessages(From, To), "Pending");
46+
47+
try
48+
{
49+
if (PendingQueue)
50+
PrintMessages(queue.PeekPendingMessages(From, To), "Pending");
4851
}
49-
if (InProgressQueue) {
50-
PrintMessages(queue.PeekInProgressMessages(From, To), "In-progress");
52+
catch (Exception exception)
53+
{
54+
Log.Warn(exception);
5155
}
52-
if (FailedQueue) {
53-
PrintMessages(queue.PeekFailedMessages(From, To), "Failed");
56+
57+
try
58+
{
59+
if (InProgressQueue)
60+
PrintMessages(queue.PeekInProgressMessages(From, To), "In-progress");
61+
}
62+
catch (Exception exception)
63+
{
64+
Log.Warn(exception);
65+
}
66+
67+
try
68+
{
69+
if (FailedQueue)
70+
PrintMessages(queue.PeekInProgressMessages(From, To), "In-progress");
71+
}
72+
catch (Exception exception)
73+
{
74+
Log.Warn(exception);
5475
}
5576
}
5677

5778
public void PrintMessages(List<ICommandEnvelope> messages, string queueName)
5879
{
5980
WarningText($"{queueName}:");
60-
if (!messages.Any()) {
81+
if (!messages.Any())
6182
Line(" no messages available.");
62-
}
63-
83+
6484
Newline();
6585

6686
var konsoleForm = new Form(120, new ThinBoxStyle());

0 commit comments

Comments
 (0)