Base solution for your next web application
Ends in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

Throwing And Displaying UserFriendlyException Using abp.services.app #7466


User avatar
0
dexmox created

Hi Again,

Thanks in advance.

What would cause throw new UserFriendlyException to not display a popup with the message in one section of my app but show the popup in another ?

They both log to log.txt


5 Answer(s)
  • User Avatar
    0
    maliming created
    Support Team

    I didn't understand it right. Can you share a few screenshots?

  • User Avatar
    0
    dexmox created

    Sorry for being unclear, please let me know if this helps clarify

    I am trying to throw an exception from AppService

    public async Task Example1(EntityDto<long> input)
    {
        throw new UserFriendlyException(L("AlreadyExists"));
    }
    

    called with abp.services.app in a datatable rowAction item

    abp.services.app.exampleItems.Example1({ id: data.record.id }).done(function () {
        // on done callback  
    }).always(function () {
        // always callback
    });
    

    AppService throws error to log file, but does not show alert box on UI.

    However another app service throws the same exception and it works, is being called using abp.services.app aswell but it is not in a datatable rowAction.

  • User Avatar
    0
    ryancyq created
    Support Team

    Hi, are you using jquery version ANZ? If so what is your project version?

    Can you share the http responses from both API? Did both of them contain the user friendly message?

    if possible, please share the code for both API call/usage in your application.

  • User Avatar
    0
    dexmox created

    Hi @ryancyq,

    Below is the information, the ApplicationService that is not working is the basic implementation above just an api method that throws new UserFriendlyException

    Version : v7.0.0.0 [20190808] Type: Jquery MVC

    ApplicationService 1 : - F12 Developer Tools Console Message 500 (Internal Server Error) No Result Object Response Log File (Not Showing Popup Modal on UI):

    WARN  2019-08-09 15:28:44,687 [136  ] Mvc.ExceptionHandling.AbpExceptionFilter - [Already Exists]
    Abp.UI.UserFriendlyException: [Already Exists]
       at xxx.xxx.xxxAppService.xxx(EntityDto`1 input) in C:\Users\xxxAppService.cs:line 831
       at lambda_method(Closure , Object )
       at Microsoft.AspNetCore.Mvc.Internal.ActionMethodExecutor.AwaitableResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
       at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeActionMethodAsync()
       at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeNextActionFilterAsync()
       at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Rethrow(ActionExecutedContext context)
       at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
       at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeInnerFilterAsync()
       at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeNextExceptionFilterAsync()
    INFO  2019-08-09 15:28:44,693 [136  ] .Mvc.Infrastructure.ObjectResultExecutor - Executing ObjectResult, writing value of type 'Abp.Web.Models.AjaxResponse'.
    INFO  2019-08-09 15:28:44,694 [136  ] ore.Mvc.Internal.ControllerActionInvoker - Executed action xxx.Services.xxxAppService.xxx (xxx.Application) in 82.7884ms
    INFO  2019-08-09 15:28:44,694 [136  ] ft.AspNetCore.Routing.EndpointMiddleware - Executed endpoint 'xxx.Services.xxxAppService.xxx (xxx.Application)'
    INFO  2019-08-09 15:28:44,694 [136  ] soft.AspNetCore.Hosting.Internal.WebHost - Request finished in 103.9412ms 500 application/json; charset=utf-8
    

    Application Service 2: - F12 Developer Tools Console Message 500 (Internal Server Error) Result Object Received with message Log File (Popup showing UI):

    WARN  2019-08-09 15:34:25,098 [201  ] Mvc.ExceptionHandling.AbpExceptionFilter - [Already Exists]
    Abp.UI.UserFriendlyException: [Already Exists]
       at xxx.xxx.xxxAppService.xxx(Int64 xId, Int64 xxId, String code) in C:\xxx\xxxAppService.cs:line 955
       at lambda_method(Closure , Object )
       at Microsoft.AspNetCore.Mvc.Internal.ActionMethodExecutor.AwaitableResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
       at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeActionMethodAsync()
       at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeNextActionFilterAsync()
       at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Rethrow(ActionExecutedContext context)
       at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
       at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeInnerFilterAsync()
       at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeNextExceptionFilterAsync()
    INFO  2019-08-09 15:34:25,098 [201  ] .Mvc.Infrastructure.ObjectResultExecutor - Executing ObjectResult, writing value of type 'Abp.Web.Models.AjaxResponse'.
    INFO  2019-08-09 15:34:25,098 [201  ] ore.Mvc.Internal.ControllerActionInvoker - Executed action xxx.xxx.xxxAppService.xxx (xxx.Application) in 97.0023ms
    INFO  2019-08-09 15:34:25,098 [201  ] ft.AspNetCore.Routing.EndpointMiddleware - Executed endpoint 'xxx.xxx.xxx.xxx (xxx.Application)'
    INFO  2019-08-09 15:34:25,099 [201  ] soft.AspNetCore.Hosting.Internal.WebHost - Request finished in 155.0018ms 500 application/json; charset=utf-8
    
  • User Avatar
    0
    dexmox created

    Thanks everyone, issue resolved: was a script import causing issue.

    Sorry for wasting time.