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

and this from controller

and this from service

Markdown is supported
Copy & paste or drag & drop images (max 30 MB per image)

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

    What exception?

    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)
  • 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

    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)
  • User Avatar
    0
    aaron created
    Support Team

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

    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)
  • User Avatar
    0
    samara081 created

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

    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)
  • User Avatar
    0
    aaron created
    Support Team

    Then what happens?

    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)
  • 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

    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)
  • User Avatar
    0
    samara081 created

    i solve it thank you

    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)