예제 #1
0
        /// <summary>
        /// Constructs an error from parameters.
        /// </summary>
        /// <param name="error">The GOLANG error string.</param>
        /// <param name="type">Optionally specifies the error type.  This defaults to <see cref="CadenceErrorType.Custom"/>.</param>
        public CadenceError(string error, CadenceErrorType type = CadenceErrorType.Custom)
        {
            Covenant.Requires <ArgumentNullException>(!string.IsNullOrEmpty(error), nameof(error));

            this.String = error;
            this.SetErrorType(type);
        }
예제 #2
0
        /// <summary>
        /// Converts an <see cref="CadenceErrorType"/> into a error string.
        /// </summary>
        /// <param name="type">the error type.</param>
        /// <returns>The error string.</returns>
        internal static string ErrorTypeToString(CadenceErrorType type)
        {
            switch (type)
            {
            case CadenceErrorType.Cancelled:   return("cancelled");

            case CadenceErrorType.Custom:      return("custom");

            case CadenceErrorType.Generic:     return("generic");

            case CadenceErrorType.Panic:       return("panic");

            case CadenceErrorType.Terminated:  return("terminated");

            case CadenceErrorType.Timeout:     return("timeout");

            default:

                throw new NotImplementedException();
            }
        }
예제 #3
0
 /// <summary>
 /// Sets the error type.
 /// </summary>
 /// <param name="type">The new type.</param>
 internal void SetErrorType(CadenceErrorType type)
 {
     Type = ErrorTypeToString(type);
 }