9 Replies - 2276 Views - Last Post: 18 October 2010 - 02:03 PM Rate Topic: -----

#1 Fortynine  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 08-October 10

Custom client side error messages

Posted 08 October 2010 - 02:36 PM

Hey all,

I'm developing an application which consists of the following parts:

The server:
-A SQL Server database
-Web services which provide the communication between the client and server

The client which uses SOAP to communicate with the web services.

When a server side error occurs, the error the user sees on the client side is a Soap error. I can specify error text, but it is buried in the SOAP error. I made a little test app which consists of a web service and WPF window. When I have it throw an error, I get things along the line of:

System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> WebService1.CustomException: Some error text like cannot connect to databaswe
at WebService1.Service1.HelloWorld()


In this example, I want the client application to display the error:

Some error text like cannot connect to databaswe


I specifically want to generate a custom error when the web services are unable to connect to the SQL Server. Instead of returning an intimidating error saying "unable to establish a connection because the server is unavailable or does not exist etc etc", I want it to say something along the lines of "The SQL Server is currently unavailable. Please check your Windows Services and make sure it is running."

The trick is, I want to do this without parsing the error message returned by the web server on the client side to determine which user friendly error to throw.

I'm looking at a couple different options, but I'm kind of just fishing around. If anyone could point me in a specific direction I would greatly appreciate it.

If you would like additional information or feel that this would be better off in a different section of the forums, please let me know.

Thanks!

Is This A Good Question/Topic? 0
  • +

Replies To: Custom client side error messages

#2 eclipsed4utoo  Icon User is offline

  • Not Your Ordinary Programmer
  • member icon

Reputation: 1524
  • View blog
  • Posts: 5,957
  • Joined: 21-March 08

Re: Custom client side error messages

Posted 10 October 2010 - 07:21 AM

here is a good post on custom ASP.Net error pages.

http://aspnetresourc...ustomErrorPages
Was This Post Helpful? 1
  • +
  • -

#3 Fortynine  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 08-October 10

Re: Custom client side error messages

Posted 11 October 2010 - 07:40 AM

View Posteclipsed4utoo, on 10 October 2010 - 06:21 AM, said:

here is a good post on custom ASP.Net error pages.

http://aspnetresourc...ustomErrorPages



That's along the lines of everything I've come across so far in researching this. The client is a winforms application. I feel like I must not be understanding how to use custom error pages to generate a custom error box client side. For example, as it stands now, if a person were to try and log in and the SQL Server were stopped, the following appears:

Posted Image

Was This Post Helpful? 0
  • +
  • -

#4 Jayman  Icon User is offline

  • Student of Life
  • member icon

Reputation: 418
  • View blog
  • Posts: 9,532
  • Joined: 26-December 05

Re: Custom client side error messages

Posted 11 October 2010 - 09:44 AM

I'm confused, is this for a web application or a windows application?

The answer will vary and depend on which type of solution you are developing.
Was This Post Helpful? 0
  • +
  • -

#5 Fortynine  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 08-October 10

Re: Custom client side error messages

Posted 11 October 2010 - 11:54 AM

Windows application, sorry I didn't make that clearer.
Was This Post Helpful? 0
  • +
  • -

#6 Fortynine  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 08-October 10

Re: Custom client side error messages

Posted 11 October 2010 - 12:12 PM

When the error is related to the web services themselves, I was thinking I could redirect to a custom error page which contains the error text I want displayed. For example, when the App Pool is stopped, the user sees the following error when trying to log in:
Posted Image

I would set up a custom error page for the 503 error, and it would pass the custom error page message to the client, causing the error window which pops up client-side to display the custom error. Does this sound correct?

If that is correct, I'm still at a loss as to how to customize errors which aren't a web exception for which I can create a custom error page.

Thanks.
Was This Post Helpful? 0
  • +
  • -

#7 Jayman  Icon User is offline

  • Student of Life
  • member icon

Reputation: 418
  • View blog
  • Posts: 9,532
  • Joined: 26-December 05

Re: Custom client side error messages

Posted 11 October 2010 - 01:39 PM

Ok, now that we have established this is a windows application. You need to catch the error in the application using a Try/Catch and then display whatever message you choose to the user.

This will be done in the client application and not in the web applications or web service.

For WebExceptions, just catch System.Net.WebException. You can get the status code from the HTTPWebRequest object and then display a user friendly message of your choice to the user.
Was This Post Helpful? 0
  • +
  • -

#8 Fortynine  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 08-October 10

Re: Custom client side error messages

Posted 12 October 2010 - 06:05 PM

View PostJayman, on 11 October 2010 - 12:39 PM, said:

Ok, now that we have established this is a windows application. You need to catch the error in the application using a Try/Catch and then display whatever message you choose to the user.

This will be done in the client application and not in the web applications or web service.

For WebExceptions, just catch System.Net.WebException. You can get the status code from the HTTPWebRequest object and then display a user friendly message of your choice to the user.


That was my first thought, but there are two problems with that approach.
First, server side errors reach the client as SOAP errors. The client doesn't know anything about the error beyond that.
Second, the error which reaches the client could be due to multiple things, each one requiring a unique response/message. For example, the user could receive an error logging in because the user name/password is incorrect, the server didn't respond, the web services were unable to communicate with SQL Server.

I'm thinking of creating custom error pages to redirect to according to the error. This seems like the best option at the moment, however that depends on the redirect page being different for different errors, which is something I've yet to come across in my reading.
Was This Post Helpful? 0
  • +
  • -

#9 Jayman  Icon User is offline

  • Student of Life
  • member icon

Reputation: 418
  • View blog
  • Posts: 9,532
  • Joined: 26-December 05

Re: Custom client side error messages

Posted 13 October 2010 - 07:10 AM

Naturally the client is going to receive the SOAP exception. But I still don't see why that is such a problem.

Perhaps there is something else about this project that you haven't told us?

SoapException

Exception Handling in Web Services
Was This Post Helpful? 0
  • +
  • -

#10 Fortynine  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 08-October 10

Re: Custom client side error messages

Posted 18 October 2010 - 02:03 PM

View PostJayman, on 13 October 2010 - 06:10 AM, said:

Naturally the client is going to receive the SOAP exception. But I still don't see why that is such a problem.

Perhaps there is something else about this project that you haven't told us?

SoapException

Exception Handling in Web Services



It's not a technical problem per se, more of an aesthetics issue. People get scared of error messages they can't understand, even when the message is relaying a relatively mundane error which is easily fixed.

Thanks for the links, SOAPException is definitely a step in the path towards what I'm trying to accomplish. I think what I'm going to end up doing is use a SOAP Extension server side to check messages leaving the server for an exception, and if it finds one, adjust the message accordingly.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1