blob: d55b622cb9a43de8cb3f2d5da1d238e26b6a4c67 (
plain)
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
|
using Google.Protobuf;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Tango.PMR;
using Tango.PMR.Common;
namespace Tango.Transport
{
/// <summary>
/// Represents a tango message response exception which indicates a response container with <see cref="ErrorCode"/> different from <see cref="ErrorCode.None"/>.
/// </summary>
/// <seealso cref="System.Exception" />
public class ResponseErrorException : Exception
{
/// <summary>
/// Gets or sets the container.
/// </summary>
public MessageContainer Container { get; set; }
/// <summary>
/// Initializes a new instance of the <see cref="ResponseErrorException{T}"/> class.
/// </summary>
/// <param name="error">The error.</param>
public ResponseErrorException(MessageContainer container, String requestName) : base(
container.Error != ErrorCode.GeneralError || String.IsNullOrEmpty(container.ErrorMessage) ?
$"{requestName} has returned with an error ({container.Error})\n{container.ErrorMessage}"
:
$"{requestName} failed.\n{container.ErrorMessage}")
{
Container = container;
}
}
}
|