in src/Framing/Error.cs [51:100]
internal static Error FromException(Exception exception, bool includeErrorDetails = false)
{
AmqpException amqpException = exception as AmqpException;
if (amqpException != null)
{
return amqpException.Error;
}
Error error = new Error();
error.Description = exception.Message;
if (exception is UnauthorizedAccessException)
{
error.Condition = AmqpErrorCode.UnauthorizedAccess;
}
else if (exception is InvalidOperationException)
{
error.Condition = AmqpErrorCode.NotAllowed;
}
else if (exception is System.Transactions.TransactionAbortedException)
{
error.Condition = AmqpErrorCode.TransactionRollback;
}
else if (exception is NotImplementedException)
{
error.Condition = AmqpErrorCode.NotImplemented;
}
else
{
error.Condition = AmqpErrorCode.InternalError;
error.Description = includeErrorDetails ?
exception.Message :
AmqpResources.GetString(AmqpResources.AmqpErrorOccurred, AmqpErrorCode.InternalError);
}
#if DEBUG
error.Info = new Fields();
const int MaxSizeInInfoMap = 8 * 1024;
// Limit the size of the exception string as it may exceed the connection max frame size
string exceptionString = exception.ToString();
if (exceptionString.Length > MaxSizeInInfoMap)
{
exceptionString = exceptionString.Substring(0, MaxSizeInInfoMap);
}
error.Info.Add("exception", exceptionString);
#endif
return error;
}