Пример #1
0
        /// <summary>
        /// Function to repackage an arbitrary exception as an Gorgon exception.
        /// </summary>
        /// <param name="result">Result code to use.</param>
        /// <param name="ex">Exception to capture and rethrow.</param>
        /// <returns>A new Gorgon exception to throw.</returns>
        /// <remarks>The original exception will be the inner exception of the new <see cref="T:GorgonLibrary.GorgonException"/>.</remarks>
        /// <exception cref="System.ArgumentNullException">Thrown when the <paramref name="ex"/> parameter is NULL (or Nothing in VB.NET).</exception>
        public static GorgonException Repackage(GorgonResult result, Exception ex)
        {
            if (ex == null)
            {
                throw new ArgumentNullException("ex");
            }

            return(new GorgonException(result, ex));
        }
Пример #2
0
 /// <summary>
 /// Serialized constructor.
 /// </summary>
 /// <param name="info">Serialization info.</param>
 /// <param name="context">Serialization context.</param>
 protected GorgonException(SerializationInfo info, StreamingContext context)
     : base(info, context)
 {
     if (info.FullTypeName == typeof(GorgonResult).FullName)
     {
         ResultCode = (GorgonResult)info.GetValue("ResultCode", typeof(GorgonResult));
     }
     else
     {
         ResultCode = new GorgonResult("Exception", info.GetInt32("HResult"), info.GetString("Message"));
     }
 }
Пример #3
0
 /// <summary>
 /// Default constructor.
 /// </summary>
 public GorgonException()
 {
     ResultCode = new GorgonResult("GorgonException", int.MinValue, string.Empty);
 }
Пример #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GorgonException"/> class.
 /// </summary>
 /// <param name="result">The result.</param>
 public GorgonException(GorgonResult result)
     : this(result, null, null)
 {
 }
Пример #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GorgonException"/> class.
 /// </summary>
 /// <param name="result">The result.</param>
 /// <param name="inner">The inner exception.</param>
 public GorgonException(GorgonResult result, Exception inner)
     : this(result, null, inner)
 {
 }
Пример #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GorgonException"/> class.
 /// </summary>
 /// <param name="result">The result.</param>
 /// <param name="message">Message data to append to the error.</param>
 public GorgonException(GorgonResult result, string message)
     : base(result.Description + (!string.IsNullOrEmpty(message) ? "\n" + message : string.Empty))
 {
     ResultCode = result;
 }
Пример #7
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="errorMessage">Error message to display.</param>
 public GorgonException(string errorMessage)
     : base(errorMessage)
 {
     ResultCode = new GorgonResult("GorgonException", HResult, errorMessage);
 }