aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.Transport/ResponseErrorException.cs
blob: 3bb5023ca9ca54db983b0c0a85613468d278d4e0 (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
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) : base(String.Format("{0} has returned with an error ({1}).{2}{3}", container.Type.ToString(), container.Error.ToString(), Environment.NewLine, container.ErrorMessage))
        {
            Container = container;
        }
    }
}