users@grizzly.java.net

Re: Handling Exceptions in Grizzly Adapter

From: Oleksiy Stashok <oleksiy.stashok_at_oracle.com>
Date: Thu, 14 Oct 2010 14:53:00 +0200

Hi,

> Following the basic getting started guide, all the examples I can
> find don't
> bother handling exceptions. What's the preferred approach?
>
> For example, I keep seeing...
>
> @Override
> public void service(GrizzlyRequest request, GrizzlyResponse
> response) {
> try {
> response.getWriter().println("hello world")));
> } catch (IOException e) {
> // nothing
> }
> }
>
> where getWriter may throw the IOException. How do you control error
> responses etc (I can't add some error message to the response using
> getWriter eg).
Can I ask you to file an issue for this [1]?
I think the best solution would be to allow Exceptions in the service
method:

public void service(GrizzlyRequest request, GrizzlyResponse response)
throws Exception;

In general, I don't think we can do much, when you get IOException
during write.print..() operation call, it probably means client
unexpectedly closed the connection, so the error can't be actually
sent to the client.
If it's not IOException, or IOException is not related to the client
connection - you can send error response back using
response.sendError(...);

Hope this will help.

WBR,
Alexey.

[1] https://grizzly.dev.java.net/issues/

>
> Cheers
> --
> View this message in context: http://old.nabble.com/Handling-Exceptions-in-Grizzly-Adapter-tp29959381p29959381.html
> Sent from the Grizzly - Users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_grizzly.dev.java.net
> For additional commands, e-mail: users-help_at_grizzly.dev.java.net
>