public AuditLogInfoToAuditLogConverter(IGuidGenerator guidGenerator, IExceptionToErrorInfoConverter exceptionToErrorInfoConverter, IJsonSerializer jsonSerializer, IOptions <AbpExceptionHandlingOptions> exceptionHandlingOptions)
 {
     GuidGenerator = guidGenerator;
     ExceptionToErrorInfoConverter = exceptionToErrorInfoConverter;
     JsonSerializer           = jsonSerializer;
     ExceptionHandlingOptions = exceptionHandlingOptions.Value;
 }
예제 #2
0
 public UserExceptionInformer(
     IUiMessageService messageService,
     IExceptionToErrorInfoConverter exceptionToErrorInfoConverter,
     IOptions <AbpExceptionHandlingOptions> options)
 {
     MessageService = messageService;
     ExceptionToErrorInfoConverter = exceptionToErrorInfoConverter;
     Options = options.Value;
     Logger  = NullLogger <UserExceptionInformer> .Instance;
 }
예제 #3
0
        public AbpExceptionFilter(
            IExceptionToErrorInfoConverter errorInfoConverter,
            IHttpExceptionStatusCodeFinder statusCodeFinder,
            IJsonSerializer jsonSerializer,
            IOptions <AbpExceptionHandlingOptions> exceptionHandlingOptions)
        {
            _errorInfoConverter       = errorInfoConverter;
            _statusCodeFinder         = statusCodeFinder;
            _jsonSerializer           = jsonSerializer;
            _exceptionHandlingOptions = exceptionHandlingOptions.Value;

            Logger = NullLogger <AbpExceptionFilter> .Instance;
        }
예제 #4
0
 public ErrorController(
     IExceptionToErrorInfoConverter exceptionToErrorInfoConverter,
     IHttpExceptionStatusCodeFinder httpExceptionStatusCodeFinder,
     IOptions <AbpErrorPageOptions> abpErrorPageOptions,
     IStringLocalizer <AbpUiResource> localizer,
     IExceptionNotifier exceptionNotifier,
     IOptions <AbpExceptionHandlingOptions> exceptionHandlingOptions)
 {
     _errorInfoConverter       = exceptionToErrorInfoConverter;
     _statusCodeFinder         = httpExceptionStatusCodeFinder;
     _localizer                = localizer;
     _exceptionNotifier        = exceptionNotifier;
     _exceptionHandlingOptions = exceptionHandlingOptions.Value;
     _abpErrorPageOptions      = abpErrorPageOptions.Value;
 }
    protected virtual RemoteServiceErrorInfo CreateErrorInfoWithoutCode(Exception exception, AbpExceptionHandlingOptions options)
    {
        if (options.SendExceptionsDetailsToClients)
        {
            return(CreateDetailedErrorInfoFromException(exception, options.SendStackTraceToClients));
        }

        exception = TryToGetActualException(exception);

        if (exception is AbpRemoteCallException remoteCallException && remoteCallException.Error != null)
        {
            return(remoteCallException.Error);
        }

        if (exception is AbpDbConcurrencyException)
        {
            return(new RemoteServiceErrorInfo(L["AbpDbConcurrencyErrorMessage"]));
        }

        if (exception is EntityNotFoundException)
        {
            return(CreateEntityNotFoundError(exception as EntityNotFoundException));
        }

        var errorInfo = new RemoteServiceErrorInfo();

        if (exception is IUserFriendlyException || exception is AbpRemoteCallException)
        {
            errorInfo.Message = exception.Message;
            errorInfo.Details = (exception as IHasErrorDetails)?.Details;
        }

        if (exception is IHasValidationErrors)
        {
            if (errorInfo.Message.IsNullOrEmpty())
            {
                errorInfo.Message = L["ValidationErrorMessage"];
            }

            if (errorInfo.Details.IsNullOrEmpty())
            {
                errorInfo.Details = GetValidationErrorNarrative(exception as IHasValidationErrors);
            }

            errorInfo.ValidationErrors = GetValidationErrorInfos(exception as IHasValidationErrors);
        }

        TryToLocalizeExceptionMessage(exception, errorInfo);

        if (errorInfo.Message.IsNullOrEmpty())
        {
            errorInfo.Message = L["InternalServerErrorMessage"];
        }

        errorInfo.Data = exception.Data;

        return(errorInfo);
    }