Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Custom Error handling in ASP MVC

I want to go beyond the default error handling given in ASP mvc. I have an errors controller, so I can hopefully give different error messages according to whats happened: i.e Invalid arguments, Permission denied, OMG DATABASE DEAD, etc.

But I cant seem to work out how to do this, this is what I have tried:

[HandleError(View="/Errors/InvalidArgument",ExceptionType=typeof(ArgumentException))]

It ends up giving a Runtime Error.

Also, on the same subject, is it possible to add more parameters that I could pass to the error controller, such as:

[HandleError(View="/Errors/InvalidArgument",ExceptionType=typeof(ArgumentException), Error="dumb arguments")]

Thanks

like image 908
Chris James Avatar asked Nov 05 '22 22:11

Chris James


1 Answers

Just specify the View name, not it's path...as for passing arguments, I don't think you can.

like image 75
Kieron Avatar answered Nov 12 '22 09:11

Kieron