A method have some methods and also some methods have other methods.
How should I pass an error message to the top method to show the message on the window or the dialog box?
It may not be an error message but an caution message or something.
It would be really nice if you give me an advice about ASP.NET MVC. In ASP.NET MVC, action methods would be the top.
A method have some methods and also some methods have other methods. How should
Share
One possibility is to use the
TryXXXpattern:and in your controller:
Another possibility is to pass the
ModelStateto the lower layers which will take care of adding the error messages to it so that in your controller action you just need to checkModelState.IsValidafter calling some method.Yet another possibility is to use exceptions but remember that exceptions should be used only to handle exceptional cases. They should be avoided to handle business validation.
There really are different ways and it all depend on what exactly you are trying to do.