internal AuthServiceException( ServiceErrorType errorType, HttpStatusCode proposedStatusCode, string message = null, Exception innerException = null, HttpStatusCode serviceStatusCode = default( HttpStatusCode ) ) : base( errorType, proposedStatusCode, message, innerException, serviceStatusCode ) {}
public ServiceError(IService service, ServiceErrorType errorType, DateTime datetime, string text) { this.Service = service; this.ErrorType = errorType; this.DateTime = datetime; this.Text = text; }
/// <summary> /// Initialize the properties of <c>ServiceException</c> using the /// provided values. /// </summary> /// /// <param name="errorType"> /// The type of error that resulted in this exception. /// See <see cref="D2L.Services.Core.Exceptions.ServiceErrorType"> /// ServiceErrorType</see>. If the error type is <c>ErrorResponse</c>, /// you must provide a value for <paramref name="serviceStatusCode" />. /// </param> /// <param name="proposedStatusCode">The suggested status code for the /// consumer to respond with. If this exception is uncaught, the /// consumer should use this status code instead of 500 Internal Server /// Error.</param> /// <param name="message">The error message that explains the reason for /// the exception.</param> /// <param name="innerException">The exception that is the cause of the /// current exception</param> /// <param name="serviceStatusCode">The status code received from the /// service. This value is only meaningful when /// <paramref name="errorType" /> is <c>ErrorResponse</c></param> /// /// <exception cref="System.ArgumentException">An error type of /// <c>ErrorResponse</c> was given, but no value was provided for /// <paramref name="serviceStatusCode"/>.</exception> protected ServiceException( ServiceErrorType errorType, HttpStatusCode proposedStatusCode, string message = null, Exception innerException = null, HttpStatusCode serviceStatusCode = default(HttpStatusCode) ) : base(message, innerException) { if ( errorType == ServiceErrorType.ErrorResponse && serviceStatusCode == default(HttpStatusCode) ) { throw new ArgumentException( "You must supply a value for the serviceStatusCode " + "parameter when errorType is ErrorResponse.", "serviceStatusCode" ); } m_errorType = errorType; m_proposedStatusCode = proposedStatusCode; m_serviceStatusCode = serviceStatusCode; }
internal AuthServiceException( ServiceErrorType errorType, HttpStatusCode proposedStatusCode, string message = null, Exception innerException = null, HttpStatusCode serviceStatusCode = default( HttpStatusCode ) ) : base( errorType, proposedStatusCode, message, innerException, serviceStatusCode ) { }
internal void A3V0urrUY(IService obj0, ServiceErrorType obj1, string obj2) { if (!this.isActive) { return; } this.OnServiceError(obj0, obj1, obj2); }
public ServiceResult(ServiceErrorType errorType, ServiceError error) { Succeeded = false; ErrorType = errorType; Errors = new ServiceErrors(); Errors.AddError(error); }
/// <summary> /// Конструирует исключение /// <param name="code">Код исключения</param> /// <param name="message">Текст исключения</param> /// </summary> public ServiceError(int code, string message) : this() { ErrorCode = code; Message = message; Type = ServiceErrorType.Exception; }
public StubServiceException( ServiceErrorType errorType, string message = null, Exception innerException = null, HttpStatusCode serviceStatusCode = default(HttpStatusCode) ) : base(errorType, message, innerException, serviceStatusCode) { }
internal void SetServiceError(IService service, ServiceErrorType errorType, string text) { if (!this.isActive) { return; } this.OnServiceError(service, errorType, text); }
/// <summary> /// Initialize the properties of <c>ServiceException</c> using the /// provided values. /// /// The <c>ProposedStatusCode</c> property is automatically determined /// by <paramref name="errorType"/> and, if applicable, /// <paramref name="serviceStatusCode"/>. /// </summary> /// /// <param name="errorType"> /// The type of error that resulted in this exception. /// See <see cref="D2L.Services.Core.Exceptions.ServiceErrorType"> /// ServiceErrorType</see>. If the error type is <c>ErrorResponse</c>, /// you must provide a value for <paramref name="serviceStatusCode" />. /// </param> /// <param name="message">The error message that explains the reason for /// the exception.</param> /// <param name="innerException">The exception that is the cause of the /// current exception</param> /// <param name="serviceStatusCode">The status code received from the /// service. This value is only meaningful when /// <paramref name="errorType" /> is <c>ErrorResponse</c></param> /// /// <exception cref="System.ArgumentException">An error type of /// <c>ErrorResponse</c> was given, but no value was provided for /// <paramref name="serviceStatusCode"/>.</exception> protected ServiceException( ServiceErrorType errorType, string message = null, Exception innerException = null, HttpStatusCode serviceStatusCode = default(HttpStatusCode) ) : base(message, innerException) { if ( errorType == ServiceErrorType.ErrorResponse && serviceStatusCode == default(HttpStatusCode) ) { throw new ArgumentException( "You must supply a value for the serviceStatusCode " + "parameter when errorType is ErrorResponse.", "serviceStatusCode" ); } m_errorType = errorType; m_serviceStatusCode = serviceStatusCode; switch (errorType) { case ServiceErrorType.ConnectionFailure: case ServiceErrorType.ClientError: m_proposedStatusCode = HttpStatusCode.BadGateway; break; case ServiceErrorType.Timeout: m_proposedStatusCode = HttpStatusCode.GatewayTimeout; break; case ServiceErrorType.CircuitOpen: m_proposedStatusCode = HttpStatusCode.ServiceUnavailable; break; case ServiceErrorType.ErrorResponse: if ( ( int )serviceStatusCode >= 400 && serviceStatusCode != HttpStatusCode.InternalServerError ) { m_proposedStatusCode = serviceStatusCode; } else { m_proposedStatusCode = HttpStatusCode.BadGateway; } break; default: m_proposedStatusCode = HttpStatusCode.InternalServerError; break; } }
/// <summary> /// Создает ненулевой объект для репорта об ошибке /// </summary> protected static ServiceEnumerationResult <T> GenerateEnumerationError <T>( string msg, int errorCode = 0, ServiceErrorType type = ServiceErrorType.Exception) { return(new ServiceEnumerationResult <T> { Error = new ServiceError { Message = msg, ErrorCode = errorCode, Type = type }, IsSucceeded = false }); }
private async Task RunTest_ExpectServiceException( HttpClient mockClient, ServiceErrorType expectedErrorType, string expectedMessage = null ) { ServiceException exception = null; try { await RunTestHelper(mockClient); } catch (ServiceException ex) { exception = ex; } Assert.IsNotNull(exception); Assert.AreEqual(expectedErrorType, exception.ErrorType); if (expectedMessage != null) { Assert.AreEqual(expectedMessage, exception.Message); } }
/// <summary> /// Initializes a new instance of the <see cref="ServiceResponse{T}"/> class. /// Initializes a new instance of the ServiceResponse class. /// </summary> /// <param name="status"> /// The status. /// </param> /// <param name="message"> /// The message. /// </param> /// <param name="errorMessage"></param> public ServiceResponse(ServiceStatus status, string message = "", string errorMessage = "", Exception exception = null, int amount = 0, int start = 0, T data = default(T), String stringData = null, ServiceErrorType errorType = ServiceErrorType.General) : this() { Status = status; Message = message; Amount = amount; Start = start; Data = data; StringData = stringData; ServiceErrorType = errorType; if (exception != null) { ErrorMessage = exception.Message; Message = exception.GetInnermostExceptionMessage(); Status = ServiceStatus.Error; } else if (!string.IsNullOrEmpty(errorMessage)) { ErrorMessage = errorMessage; Status = ServiceStatus.Error; } }
internal void A3V0urrUY(IService obj0, ServiceErrorType obj1, string obj2) { if (!this.isActive) return; this.OnServiceError(obj0, obj1, obj2); }
protected virtual void OnServiceError(IService service, ServiceErrorType errorType, string text) { }
public static ServiceResult Failed(ServiceErrorType errorType, Exception e = null) { return(new ServiceResult(errorType, new ServiceError(string.Empty, e))); }
public static ServiceResult Failed(ServiceErrorType errorType, ServiceErrors errors = null) { return(new ServiceResult(errorType, errors)); }
public ServiceError(string message, ServiceErrorType serviceErrorType) : base(message) { ServiceErrorType = serviceErrorType; }
public ServiceResult(ServiceErrorType errorType, ServiceErrors errors) { Succeeded = false; ErrorType = errorType; Errors = errors; }
/// <summary> /// Конструирует ошибку /// <param name="code">Код ошибки</param> /// <param name="message">Текст ошибки</param> /// <param name="type">Тип ошибки</param> /// </summary> public ServiceError(int code, string message, ServiceErrorType type) : this(code, message) { Type = type; }
/// <summary> /// Конструирует пустое исключение /// </summary> public ServiceError() { Type = ServiceErrorType.Exception; }
private async Task RunTest_ExpectServiceException( HttpClient mockClient, ServiceErrorType expectedErrorType, string expectedMessage = null ) { ServiceException exception = null; try { await RunTestHelper( mockClient ); } catch( ServiceException ex ) { exception = ex; } Assert.IsNotNull( exception ); Assert.AreEqual( expectedErrorType, exception.ErrorType ); if( expectedMessage != null ) { Assert.AreEqual( expectedMessage, exception.Message ); } }
public void SetError(string message, ServiceErrorType serviceErrorType) { Error = new ServiceError(message, serviceErrorType); }