Base solution for your next web application
Open Closed

Exception Handling #6998


User avatar
0
samara081 created

Please help me how to catch exception if i call service from mvc controller? if i do that my code never enter catch section in Application service but if i call sevice from java script directly all thing is ok, all my need is to not call service from javascript to catch exception

this code from View
Code from View.png

and this from controller
Code from Controller.png

and this from service
Code from Service.png


7 Answer(s)
  • User Avatar
    0
    aaron created
    Support Team

    What exception?

  • User Avatar
    0
    samara081 created

    in last statement before try block , number 2 is wrong to try entring in catch, it is foreign key reference
    so i provide the Id not exist in database

  • User Avatar
    0
    aaron created
    Support Team

    And you're saying DB inserts non-existing foreign key when called from controller?

  • User Avatar
    0
    samara081 created

    no, it is not insert and not enter the catch for this error

  • User Avatar
    0
    aaron created
    Support Team

    Then what happens?

  • User Avatar
    0
    samara081 created

    nothing
    all i need to let my code to enter to catch bloack and set error message to be shown to user

  • User Avatar
    0
    samara081 created

    i solve it
    thank you