/// <summary> /// Combines the SolidDnaError and InnerExeption, adding the InnerException message to the SolidDnaError.ErrorDescription /// </summary> /// <returns></returns> public SolidDnaError ToCompositeSolidDnaError() { var copy = new SolidDnaError(SolidDnaError); if (InnerException != null) { copy.ErrorDetails = $"{copy.ErrorDetails}. Inner Exception ({InnerException.GetType()}): {InnerException.GetErrorMessage()}"; } return(copy); }
/// <summary> /// Constructor /// </summary> /// <param name="solidDnaError">The error to clone from</param> public SolidDnaError(SolidDnaError solidDnaError) { ErrorTypeCodeValue = solidDnaError.ErrorTypeCodeValue; ErrorDetails = solidDnaError.ErrorDetails; ErrorMessage = solidDnaError.ErrorMessage; ErrorCodeValue = solidDnaError.ErrorCodeValue; PertinentData = solidDnaError.PertinentData; CallerMemberName = solidDnaError.CallerMemberName; CallerFilePath = solidDnaError.CallerFilePath; CallerLineNumber = solidDnaError.CallerLineNumber; }
/// <summary> /// Creates a <see cref="SolidDnaError"/> from the given details /// </summary> /// <param name="errorDetails">Specific details about this exact error</param> /// <param name="errorTypeCode">The error type code of this error</param> /// <param name="errorCode">The specific error code of this error</param> /// <param name="innerException">If an inner exception is supplied, its message is appended to the errorDetails</param> /// <returns></returns> public static SolidDnaError CreateError(SolidDnaErrorTypeCode errorTypeCode, SolidDnaErrorCode errorCode, string errorDetails, Exception innerException = null) { // Create the error var error = new SolidDnaError { ErrorCodeValue = errorCode, ErrorMessage = errorDetails, ErrorTypeCodeValue = errorTypeCode, }; // Set inner details if (innerException != null) { error.ErrorDetails = $"{error.ErrorDetails}. Inner Exception ({innerException.GetType()}: {innerException.GetErrorMessage()}"; } return(error); }
/// <summary> /// Default constructor /// </summary> public SolidDnaException(SolidDnaError error, Exception innerException = null) { SolidDnaError = error; InnerException = innerException; }