public void Set(HardwareErrorSeverity sev, string error) { switch (sev) { case HardwareErrorSeverity.Information: if (!informations.ContainsKey(error)) { informations.Add(error, true); } break; case HardwareErrorSeverity.Warning: if (!warnings.ContainsKey(error)) { warnings.Add(error, true); } break; case HardwareErrorSeverity.Error: if (!errors.ContainsKey(error)) { errors.Add(error, true); } break; default: throw new ArgumentOutOfRangeException("sev"); } }
/// <overload> /// Initializes a new instance of <see cref="Hardware"/> error. /// </overload> /// <summary> /// Initializes a new instance of <see cref="Hardware"/> error. /// </summary> /// <param name="severity">Severity of this error.</param> /// <param name="errorClass">The class for this error, in practice a category to group the error.</param> /// <param name="errorCode"> /// The code that uniquely identify this error. Each error code must be unique within the same error class. /// </param> /// <param name="message">Descriptive (non localized) message of this error.</param> /// <exception cref="InvalidEnumArgumentException"> /// If <paramref name="severity"/> is not a valid <see cref="HardwareErrorSeverity"/> value. /// <br/>-or-<br/> /// If <paramref name="errorClass"/> is not a valid <see cref="HardwareErrorClass"/> value. /// </exception> /// <exception cref="ArgumentException"> /// if <paramref name="message"/> is a null or blank string. /// </exception> public HardwareError(HardwareErrorSeverity severity, HardwareErrorClass errorClass, ushort errorCode, string message) { if (!Enum.IsDefined(typeof(HardwareErrorClass), errorClass)) { throw new InvalidEnumArgumentException("errorClass", (int)errorClass, typeof(HardwareErrorClass)); } if (!Enum.IsDefined(typeof(HardwareErrorSeverity), severity)) { throw new InvalidEnumArgumentException("severity", (int)severity, typeof(HardwareErrorSeverity)); } if (String.IsNullOrWhiteSpace(message)) { throw new ArgumentException("Error message cannot be a null or blank string.", "message"); } Severity = severity; Class = errorClass; Code = errorCode; Message = message; }
public ErrorState(string error, HardwareErrorSeverity sev) { Set(sev, error); }
/// <summary> /// Initializes a new instance of <see cref="Hardware"/> error to represent a generic unspecified error (with /// class <see cref="HardwareErrorClass.Generic"/> and error code 0). /// </summary> /// <param name="severity">Severity of this error.</param> /// <param name="message">Descriptive (non localized) message of this error.</param> /// <exception cref="InvalidEnumArgumentException"> /// If <paramref name="severity"/> is not a valid <see cref="HardwareErrorSeverity"/> value. /// </exception> /// <exception cref="ArgumentException"> /// if <paramref name="message"/> is a null or blank string. /// </exception> public HardwareError(HardwareErrorSeverity severity, string message) : this(severity, HardwareErrorClass.Generic, HardwareErrorCodes.Generic.Unknown, message) { }