locked
How to handle error at Action Method Level in VB MVC RRS feed

  • Question

  • User172359946 posted

    Hi

    Im trying to define an exception handler for an Action Method in a Controller, I've seen a lot of examples for C# that use this syntax:

    [HandleError(ExceptionType = typeof(SqlException), View = "DatabaseError")]]

    could you help me finding the syntax for doing the same in Visual Basic MVC 4

    thanks

    Paolo 

    Monday, January 26, 2015 11:54 AM

Answers

  • User281315223 posted

    Give this a try :

    <HandleError(ExceptionType:=GetType(SqlException), View:="DatabaseError")>

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, January 26, 2015 6:20 PM

All replies

  • User281315223 posted

    I'm not sure about the second and third parameters, but it might be something like this :

    <HandleError(GetType(SqlException),"",0,"DatabaseError")>

    This looks correct and has the correct number of attributes, but doesn't seem to want to compile properly on my machine.

    Monday, January 26, 2015 12:48 PM
  • User172359946 posted

    Yes, it doesnt compile: "too many arguments for to Public Sub New()" even if the number of argument is right even according to the syntax helper.

    Someone has ever tried to do this?  is there any example around about using action method decoration for handling exception, logging, tracing in visual basic ?

    for C# there are a lot but the syntax is different.

    Rion , thanks for your answer 

    Monday, January 26, 2015 4:08 PM
  • User281315223 posted

    Give this a try :

    <HandleError(ExceptionType:=GetType(SqlException), View:="DatabaseError")>

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, January 26, 2015 6:20 PM
  • User172359946 posted

    Yes , it works Smile

    Tuesday, January 27, 2015 6:44 AM