-
Notifications
You must be signed in to change notification settings - Fork 4.5k
/
ServiceBusException.cs
83 lines (74 loc) · 2.9 KB
/
ServiceBusException.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
namespace Microsoft.Azure.ServiceBus
{
using System;
using Primitives;
/// <summary>
/// Base Exception for various Service Bus errors.
/// </summary>
public class ServiceBusException : Exception
{
/// <summary>
/// Returns a new ServiceBusException
/// </summary>
/// <param name="isTransient">Specifies whether or not the exception is transient.</param>
public ServiceBusException(bool isTransient)
{
this.IsTransient = isTransient;
}
/// <summary>
/// Returns a new ServiceBusException
/// </summary>
/// <param name="isTransient">Specifies whether or not the exception is transient.</param>
/// <param name="message">The detailed message exception.</param>
public ServiceBusException(bool isTransient, string message)
: base(message)
{
this.IsTransient = isTransient;
}
/// <summary>
/// Returns a new ServiceBusException
/// </summary>
/// <param name="isTransient">Specifies whether or not the exception is transient.</param>
public ServiceBusException(bool isTransient, Exception innerException)
: base(innerException.Message, innerException)
{
this.IsTransient = isTransient;
}
/// <summary>
/// Returns a new ServiceBusException
/// </summary>
/// <param name="isTransient">Specifies whether or not the exception is transient.</param>
/// <param name="message">The detailed message exception.</param>
public ServiceBusException(bool isTransient, string message, Exception innerException)
: base(message, innerException)
{
this.IsTransient = isTransient;
}
/// <summary>
/// Gets the message as a formatted string.
/// </summary>
public override string Message
{
get
{
var baseMessage = base.Message;
if (string.IsNullOrEmpty(this.ServiceBusNamespace))
{
return baseMessage;
}
return "{0}, ({1})".FormatInvariant(baseMessage, this.ServiceBusNamespace);
}
}
/// <summary>
/// A boolean indicating if the exception is a transient error or not.
/// </summary>
/// <value>returns true when user can retry the operation that generated the exception without additional intervention.</value>
public bool IsTransient { get; }
/// <summary>
/// Gets the Service Bus namespace from which the exception occurred, if available.
/// </summary>
public string ServiceBusNamespace { get; internal set; }
}
}