Sean McHugh

Sean McHugh

  • NA
  • 13
  • 0

How do you handle exceptions when remoting?

Sep 30 2009 5:35 PM
client creates a remote object on the server client calls a method on that object that method throws an exception How do I handle that exception from the client. ---------------------------------------------------------------------------------------------- To be more specific I am trying to create a login system where the client creates a remote object on the server to query a database. Let's take the method ValidateUser(string username, string password) for example. I want the method to return true if the credentials are correct and false if they are not. But if any exceptions are thrown (say a problem connecting to the database) I want to catch them on the server (CORRECTION, I WANT TO CATCH THEM ON THE CLIENT) application and handle them accordingly. One solution I have thought of is to return an object with all of the possible results of the method e.g.: class MethodResults { bool exceptionThrown; string exceptionMessage; bool validUser; etc. } but that just does not seem like the right way to do it. It does work but it's such a bad technique I can't stand it. So what is the right way to catch application exceptions on the client application.

Answers (2)