summary refs log tree commit diff
path: root/crypto/src/tsp/TSPValidationException.cs
blob: ca693fa38f59ad07589492f0bb53cc19867bc5ca (plain) (blame)
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
43
44
45
46
47
using System;
using System.Runtime.Serialization;

namespace Org.BouncyCastle.Tsp
{
	/**
	 * Exception thrown if a TSP request or response fails to validate.
	 * <p>
	 * If a failure code is associated with the exception it can be retrieved using
	 * the getFailureCode() method.</p>
	 */
    [Serializable]
    public class TspValidationException
		: TspException
	{
		protected readonly int m_failureCode;

		public TspValidationException(string message)
			: this(message, -1)
		{
		}

		public TspValidationException(string message, int failureCode)
			: base(message)
		{
			m_failureCode = failureCode;
		}

		protected TspValidationException(SerializationInfo info, StreamingContext context)
			: base(info, context)
		{
			m_failureCode = info.GetInt32("failureCode");
		}

		public override void GetObjectData(SerializationInfo info, StreamingContext context)
		{
			base.GetObjectData(info, context);
			info.AddValue("failureCode", m_failureCode);
		}

		/// <returns>The failure code associated with this exception, if one is set.</returns>
		public int FailureCode
		{
			get { return m_failureCode; }
		}
	}
}