in src/NMS.AMQP/Util/ExceptionSupport.cs [147:188]
public static NMSException GetException(Error amqpErr, string message = "", Exception e = null)
{
string errCode = null;
string errMessage = null;
string additionalErrInfo = null;
if (amqpErr == null)
{
amqpErr = NMSError.INTERNAL;
}
errCode = amqpErr.Condition.ToString();
errMessage = amqpErr.Description;
errMessage = errMessage != null ? ", Description = " + errMessage : "";
if (amqpErr.Info != null && amqpErr.Info.Count > 0)
{
additionalErrInfo = ", ErrorInfo = " + Types.ConversionSupport.ToString(amqpErr.Info);
}
if (null == e)
{
// no exception given, create a NMSunthrownException to hold the
// stack and use it as the innerException in the constructors for
// the NMSexception we create., the custom StackTrace() will allow exception listeners to
// see the stack to here
e = new NMSProviderError(errCode, errMessage);
}
NMSException ex = null;
Type exType = null;
if(errTypeMap.TryGetValue(errCode, out exType))
{
ConstructorInfo ci = exType.GetConstructor(new[] { typeof(string), typeof(string), typeof(Exception) });
object inst = ci.Invoke(new object[] { message + errMessage + additionalErrInfo , errCode, e });
ex = inst as NMSException;
}
else
{
ex = new NMSException(message + errMessage + additionalErrInfo, errCode, e);
}
return ex;
}