/// <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="TemporalErrorType.Generic"/>.</param> public TemporalError(string error, TemporalErrorType type = TemporalErrorType.Generic) { Covenant.Requires <ArgumentNullException>(!string.IsNullOrEmpty(error), nameof(error)); this.String = error; this.SetErrorType(type); }
/// <summary> /// Converts an <see cref="TemporalErrorType"/> into a error string. /// </summary> /// <param name="type">the error type.</param> /// <returns>The error string.</returns> internal static string ErrorTypeToString(TemporalErrorType type) { switch (type) { case TemporalErrorType.Cancelled: return("cancelled"); case TemporalErrorType.Custom: return("custom"); case TemporalErrorType.Generic: return("generic"); case TemporalErrorType.Panic: return("panic"); case TemporalErrorType.Terminated: return("terminated"); case TemporalErrorType.Timeout: return("timeout"); default: throw new NotImplementedException(); } }
/// <summary> /// Sets the error type. /// </summary> /// <param name="type">The new type.</param> internal void SetErrorType(TemporalErrorType type) { Type = ErrorTypeToString(type); }