-
Notifications
You must be signed in to change notification settings - Fork 368
/
CommandFailed.cs
42 lines (34 loc) · 1.2 KB
/
CommandFailed.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// Copyright (c) .NET Foundation and contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using System;
using System.Text.Json.Serialization;
using Microsoft.DotNet.Interactive.Commands;
namespace Microsoft.DotNet.Interactive.Events
{
public class CommandFailed : KernelEvent
{
public CommandFailed(
Exception exception,
KernelCommand command,
string message = null) : base(command)
{
if (command is null)
{
throw new ArgumentNullException(nameof(command));
}
Exception = exception;
Message = string.IsNullOrWhiteSpace(message)
? exception?.ToString() ?? $"Command failed: {Command}"
: message;
}
public CommandFailed(
string message,
KernelCommand command) : this(null, command, message)
{
}
[JsonIgnore]
public Exception Exception { get; }
public string Message { get; set; }
public override string ToString() => $"{base.ToString()}: {Message}";
}
}