problem returning a response status

16 messages Options
Embed this post
Permalink
Patrizio Munzi

problem returning a response status

Reply Threaded More More options
Print post
Permalink
Hi everybody,

I'm trying to make work the following simple exception handling.
I just want to return the status specified.
The problem is that client side I cannot retrieve nothing, neither the exception or the exception message.

I'm surely doing it wrongly, but I haven't find any written explanation on how managing exception.

Could someone give me some hints to the right way???

Thanks

---------------
@Post
public void createUser(Representation entity) {
try {
// Parse the given representation and retrieve pairs of  
// "name=value" tokens.  
Form form = new Form(entity);  
String userId=form.getFirstValue("userId");  

myApplication.createUser(userId);

setStatus(Status.SUCCESS_CREATED, "Created User: " + userId);  
} catch(Throwable e) {

e.printStackTrace();
setStatus(Status.SERVER_ERROR_INTERNAL, e, e.getMessage());  

}
}
----------------

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2381230
Patrizio Munzi

RE: problem returning a response status

Reply Threaded More More options
Print post
Permalink
Of course it would be better being able to threw the exception till the client, but if I'm not wrong that's not possible, is it??

Opinions appreciated...!!!

Thanks

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2381294
Nicolas Rinaudo

RE: problem returning a response status

Reply Threaded More More options
Print post
Permalink
In reply to this post by Patrizio Munzi
Hi there,

Disclaimer: you're running RESTlet 2.0, with which I have very little familiarity.

With RESTlet 1.1, the way to specify a message within a status is to create a new instance of Status.

try:
setStatus(new Status(Status.SERVER_ERROR_INTERNAL, e.getMessage()));

Nicolas

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2381308
Patrizio Munzi

RE: problem returning a response status

Reply Threaded More More options
Print post
Permalink
I already tried that way, but it didn't work...!
:-(

Any other ideas??

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2381311
Laurent Rustuel-2

Re: problem returning a response status

Reply Threaded More More options
Print post
Permalink
In reply to this post by Patrizio Munzi
Hello,
Patrizio Munzi a écrit :
> I'm trying to make work the following simple exception handling.
> I just want to return the status specified.
> The problem is that client side I cannot retrieve nothing, neither the exception or the exception message.
>
> I'm surely doing it wrongly, but I haven't find any written explanation on how managing exception.
>
> Could someone give me some hints to the right way???
I think you can do the following in your catch block :
throw new ResourceException(Status.SERVER_ERROR_INTERNAL, e);
If it is not enough, try to extend StatusService class. More info in
this thread
http://restlet.markmail.org/message/ptesti33kkk5bksv?q=StatusService
Hope it help.
Regards,
Laurent.

>
> Thanks
>
> ---------------
> @Post
> public void createUser(Representation entity) {
> try {
> // Parse the given representation and retrieve pairs of  
> // "name=value" tokens.  
> Form form = new Form(entity);  
> String userId=form.getFirstValue("userId");  
>
> myApplication.createUser(userId);
>
> setStatus(Status.SUCCESS_CREATED, "Created User: " + userId);  
> } catch(Throwable e) {
>
> e.printStackTrace();
> setStatus(Status.SERVER_ERROR_INTERNAL, e, e.getMessage());  
>
> }
> }



--
Laurent Rustuel,
Alten contractor for Alcatel-Lucent, Brest

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2381318
Thierry Boileau

Re: problem returning a response status

Reply Threaded More More options
Print post
Permalink
Hello Patrizio  and Laurent,


you're right Laurent. I notice also there is a lack of documentation
about this that needs to be addressed.

best regards,
Thierry Boileau

> Hello,
> Patrizio Munzi a écrit :
>  
>> I'm trying to make work the following simple exception handling.
>> I just want to return the status specified.
>> The problem is that client side I cannot retrieve nothing, neither the exception or the exception message.
>>
>> I'm surely doing it wrongly, but I haven't find any written explanation on how managing exception.
>>
>> Could someone give me some hints to the right way???
>>    
> I think you can do the following in your catch block :
> throw new ResourceException(Status.SERVER_ERROR_INTERNAL, e);
> If it is not enough, try to extend StatusService class. More info in
> this thread
> http://restlet.markmail.org/message/ptesti33kkk5bksv?q=StatusService
> Hope it help.
> Regards,
> Laurent.
>
>  
>> Thanks
>>
>> ---------------
>> @Post
>> public void createUser(Representation entity) {
>> try {
>> // Parse the given representation and retrieve pairs of  
>> // "name=value" tokens.  
>> Form form = new Form(entity);  
>> String userId=form.getFirstValue("userId");  
>>
>> myApplication.createUser(userId);
>>
>> setStatus(Status.SUCCESS_CREATED, "Created User: " + userId);  
>> } catch(Throwable e) {
>>
>> e.printStackTrace();
>> setStatus(Status.SERVER_ERROR_INTERNAL, e, e.getMessage());  
>>
>> }
>> }
>>    
>
>
>
>

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2381361
jlouvel

RE: problem returning a response status

Reply Threaded More More options
Print post
Permalink
Hi all,

Regarding the propagation of exceptions on the client-side, I've got some plans there:

"Add exception conversion to ConverterService"
http://restlet.tigris.org/issues/show_bug.cgi?id=878

Best regards,
Jerome Louvel
--
Restlet ~ Founder and Lead developer ~ http://www.restlet.org
Noelios Technologies ~ Co-founder ~ http://www.noelios.com


-----Message d'origine-----
De : Thierry Boileau [mailto:[hidden email]]
Envoyé : vendredi 7 août 2009 18:02
À : [hidden email]
Objet : Re: problem returning a response status

Hello Patrizio  and Laurent,


you're right Laurent. I notice also there is a lack of documentation
about this that needs to be addressed.

best regards,
Thierry Boileau

> Hello,
> Patrizio Munzi a écrit :
>  
>> I'm trying to make work the following simple exception handling.
>> I just want to return the status specified.
>> The problem is that client side I cannot retrieve nothing, neither the exception or the exception message.
>>
>> I'm surely doing it wrongly, but I haven't find any written explanation on how managing exception.
>>
>> Could someone give me some hints to the right way???
>>    
> I think you can do the following in your catch block :
> throw new ResourceException(Status.SERVER_ERROR_INTERNAL, e);
> If it is not enough, try to extend StatusService class. More info in
> this thread
> http://restlet.markmail.org/message/ptesti33kkk5bksv?q=StatusService
> Hope it help.
> Regards,
> Laurent.
>
>  
>> Thanks
>>
>> ---------------
>> @Post
>> public void createUser(Representation entity) {
>> try {
>> // Parse the given representation and retrieve pairs of  
>> // "name=value" tokens.  
>> Form form = new Form(entity);  
>> String userId=form.getFirstValue("userId");  
>>
>> myApplication.createUser(userId);
>>
>> setStatus(Status.SUCCESS_CREATED, "Created User: " + userId);  
>> } catch(Throwable e) {
>>
>> e.printStackTrace();
>> setStatus(Status.SERVER_ERROR_INTERNAL, e, e.getMessage());  
>>
>> }
>> }
>>    
>
>
>
>

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2381361

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2384451
patrizio.munzi

Re: problem returning a response status

Reply Threaded More More options
Print post
Permalink
Some javascript/style in this post has been disabled (why?)
Hi everybody,

I think there's a bug or at least something strange in ResourceException management.
The getDescription method works only if I run my application in a stand-alone server.
It instead doesn't work if I run in a servlet container (tomcat 5.5).

I'm throwing the following exception server-side:
----------------------------------------------
        } catch(Throwable e) {
            throw new ResourceException(Status.SERVER_ERROR_INTERNAL, e.getMessage, e);
       }
----------------------------------------------


And here's my client code:
----------------------------------------------
        try {
            Form form = new Form(); 
            form.add("userId", userId); 
            Representation userRepresentation = form.getWebRepresentation();

            Request createUserRequest = new Request(Method.POST, createUrl);

            createUserRequest.setEntity(userRepresentation);
            Response response = client.handle(createUserRequest);
            resultStatus = response.getStatus();
        } catch (Throwable t) {
            System.err.println("Exception in creating User: " + userId + ". Exception: " + t);
        }       
        if (resultStatus.isSuccess()) { 
            System.out.println("Created User: " + userId + ". Status: " + resultStatus.getName() + " - Description: " + resultStatus.getDescription());
        }
        else {
            System.err.println("Error in creating User: " + userId + ". Status: " + resultStatus.getName() + " - Description: " + resultStatus.getDescription());
        }
----------------------------------------------


II the application runs in a servlet container I get the following message client side:

Error in creating User: TestUser. Status: Internal Server Error - Description: OK

instead in a stand alone server I get the right description:

Error in creating User: TestUser. Status: Internal Server Error - Description: Test Exception

Has anyone got any idea if it's a bug or I'm doing something wrong????

Thanks

Jerome Louvel wrote:
Hi all,

Regarding the propagation of exceptions on the client-side, I've got some plans there:

"Add exception conversion to ConverterService"
http://restlet.tigris.org/issues/show_bug.cgi?id=878

Best regards,
Jerome Louvel
--
Restlet ~ Founder and Lead developer ~ http://www.restlet.org
Noelios Technologies ~ Co-founder ~ http://www.noelios.com


-----Message d'origine-----
De : Thierry Boileau [[hidden email]] 
Envoyé : vendredi 7 août 2009 18:02
À : [hidden email]
Objet : Re: problem returning a response status

Hello Patrizio  and Laurent,


you're right Laurent. I notice also there is a lack of documentation 
about this that needs to be addressed.

best regards,
Thierry Boileau

  
Hello,
Patrizio Munzi a écrit :
  
    
I'm trying to make work the following simple exception handling.
I just want to return the status specified.
The problem is that client side I cannot retrieve nothing, neither the exception or the exception message.

I'm surely doing it wrongly, but I haven't find any written explanation on how managing exception.

Could someone give me some hints to the right way???
    
      
I think you can do the following in your catch block :
throw new ResourceException(Status.SERVER_ERROR_INTERNAL, e);
If it is not enough, try to extend StatusService class. More info in 
this thread 
http://restlet.markmail.org/message/ptesti33kkk5bksv?q=StatusService
Hope it help.
Regards,
Laurent.

  
    
Thanks

---------------
@Post
public void createUser(Representation entity) {
try {
// Parse the given representation and retrieve pairs of  
// "name=value" tokens.  
Form form = new Form(entity);  
String userId=form.getFirstValue("userId");  

myApplication.createUser(userId);

setStatus(Status.SUCCESS_CREATED, "Created User: " + userId);  
} catch(Throwable e) {

e.printStackTrace();
setStatus(Status.SERVER_ERROR_INTERNAL, e, e.getMessage());  

} 
}
    
      


    

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2381361

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2384451

  

--

Patrizio Munzi
Product Specialist
Viale Bruno Buozzi, 19 - 00197 Roma (Italy)
tel: +39 06 4543 3540
fax: +39 06 4543 3587
mobile: +39 393 7195 164
mail: [hidden email]
web: http://www.eris4.com
skype: eris4_munzi


patrizio.munzi

Re: problem returning a response status

Reply Threaded More More options
Print post
Permalink
Some javascript/style in this post has been disabled (why?)
Isn't anybody interested in this??
Restlet developers...??

I think it should be solved..

Thanks

Patrizio Munzi wrote:
Hi everybody,

I think there's a bug or at least something strange in ResourceException management.
The getDescription method works only if I run my application in a stand-alone server.
It instead doesn't work if I run in a servlet container (tomcat 5.5).

I'm throwing the following exception server-side:
----------------------------------------------
        } catch(Throwable e) {
            throw new ResourceException(Status.SERVER_ERROR_INTERNAL, e.getMessage, e);
       }
----------------------------------------------


And here's my client code:
----------------------------------------------
        try {
            Form form = new Form(); 
            form.add("userId", userId); 
            Representation userRepresentation = form.getWebRepresentation();

            Request createUserRequest = new Request(Method.POST, createUrl);

            createUserRequest.setEntity(userRepresentation);
            Response response = client.handle(createUserRequest);
            resultStatus = response.getStatus();
        } catch (Throwable t) {
            System.err.println("Exception in creating User: " + userId + ". Exception: " + t);
        }       
        if (resultStatus.isSuccess()) { 
            System.out.println("Created User: " + userId + ". Status: " + resultStatus.getName() + " - Description: " + resultStatus.getDescription());
        }
        else {
            System.err.println("Error in creating User: " + userId + ". Status: " + resultStatus.getName() + " - Description: " + resultStatus.getDescription());
        }
----------------------------------------------


II the application runs in a servlet container I get the following message client side:

Error in creating User: TestUser. Status: Internal Server Error - Description: OK

instead in a stand alone server I get the right description:

Error in creating User: TestUser. Status: Internal Server Error - Description: Test Exception

Has anyone got any idea if it's a bug or I'm doing something wrong????

Thanks

Jerome Louvel wrote:
Hi all,

Regarding the propagation of exceptions on the client-side, I've got some plans there:

"Add exception conversion to ConverterService"
http://restlet.tigris.org/issues/show_bug.cgi?id=878

Best regards,
Jerome Louvel
--
Restlet ~ Founder and Lead developer ~ http://www.restlet.org
Noelios Technologies ~ Co-founder ~ http://www.noelios.com


-----Message d'origine-----
De : Thierry Boileau [[hidden email]] 
Envoyé : vendredi 7 août 2009 18:02
À : [hidden email]
Objet : Re: problem returning a response status

Hello Patrizio  and Laurent,


you're right Laurent. I notice also there is a lack of documentation 
about this that needs to be addressed.

best regards,
Thierry Boileau

  
Hello,
Patrizio Munzi a écrit :
  
    
I'm trying to make work the following simple exception handling.
I just want to return the status specified.
The problem is that client side I cannot retrieve nothing, neither the exception or the exception message.

I'm surely doing it wrongly, but I haven't find any written explanation on how managing exception.

Could someone give me some hints to the right way???
    
      
I think you can do the following in your catch block :
throw new ResourceException(Status.SERVER_ERROR_INTERNAL, e);
If it is not enough, try to extend StatusService class. More info in 
this thread 
http://restlet.markmail.org/message/ptesti33kkk5bksv?q=StatusService
Hope it help.
Regards,
Laurent.

  
    
Thanks

---------------
@Post
public void createUser(Representation entity) {
try {
// Parse the given representation and retrieve pairs of  
// "name=value" tokens.  
Form form = new Form(entity);  
String userId=form.getFirstValue("userId");  

myApplication.createUser(userId);

setStatus(Status.SUCCESS_CREATED, "Created User: " + userId);  
} catch(Throwable e) {

e.printStackTrace();
setStatus(Status.SERVER_ERROR_INTERNAL, e, e.getMessage());  

} 
}
    
      

    

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2381361

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2384451

  

--

Patrizio Munzi
Product Specialist
Viale Bruno Buozzi, 19 - 00197 Roma (Italy)
tel: +39 06 4543 3540
fax: +39 06 4543 3587
mobile: +39 393 7195 164
mail: [hidden email]
web: http://www.eris4.com
skype: eris4_munzi


--

Patrizio Munzi
Product Specialist
Viale Bruno Buozzi, 19 - 00197 Roma (Italy)
tel: +39 06 4543 3540
fax: +39 06 4543 3587
mobile: +39 393 7195 164
mail: [hidden email]
web: http://www.eris4.com
skype: eris4_munzi



patrizio.munzi

Re: problem returning a response status

Reply Threaded More More options
Print post
Permalink
Some javascript/style in this post has been disabled (why?)
May I have a feedback at least...??

Please.

Patrizio Munzi wrote:
Isn't anybody interested in this??
Restlet developers...??

I think it should be solved..

Thanks

Patrizio Munzi wrote:
Hi everybody,

I think there's a bug or at least something strange in ResourceException management.
The getDescription method works only if I run my application in a stand-alone server.
It instead doesn't work if I run in a servlet container (tomcat 5.5).

I'm throwing the following exception server-side:
----------------------------------------------
        } catch(Throwable e) {
            throw new ResourceException(Status.SERVER_ERROR_INTERNAL, e.getMessage, e);
       }
----------------------------------------------


And here's my client code:
----------------------------------------------
        try {
            Form form = new Form(); 
            form.add("userId", userId); 
            Representation userRepresentation = form.getWebRepresentation();

            Request createUserRequest = new Request(Method.POST, createUrl);

            createUserRequest.setEntity(userRepresentation);
            Response response = client.handle(createUserRequest);
            resultStatus = response.getStatus();
        } catch (Throwable t) {
            System.err.println("Exception in creating User: " + userId + ". Exception: " + t);
        }       
        if (resultStatus.isSuccess()) { 
            System.out.println("Created User: " + userId + ". Status: " + resultStatus.getName() + " - Description: " + resultStatus.getDescription());
        }
        else {
            System.err.println("Error in creating User: " + userId + ". Status: " + resultStatus.getName() + " - Description: " + resultStatus.getDescription());
        }
----------------------------------------------


II the application runs in a servlet container I get the following message client side:

Error in creating User: TestUser. Status: Internal Server Error - Description: OK

instead in a stand alone server I get the right description:

Error in creating User: TestUser. Status: Internal Server Error - Description: Test Exception

Has anyone got any idea if it's a bug or I'm doing something wrong????

Thanks

Jerome Louvel wrote:
Hi all,

Regarding the propagation of exceptions on the client-side, I've got some plans there:

"Add exception conversion to ConverterService"
http://restlet.tigris.org/issues/show_bug.cgi?id=878

Best regards,
Jerome Louvel
--
Restlet ~ Founder and Lead developer ~ http://www.restlet.org
Noelios Technologies ~ Co-founder ~ http://www.noelios.com


-----Message d'origine-----
De : Thierry Boileau [[hidden email]] 
Envoyé : vendredi 7 août 2009 18:02
À : [hidden email]
Objet : Re: problem returning a response status

Hello Patrizio  and Laurent,


you're right Laurent. I notice also there is a lack of documentation 
about this that needs to be addressed.

best regards,
Thierry Boileau

  
Hello,
Patrizio Munzi a écrit :
  
    
I'm trying to make work the following simple exception handling.
I just want to return the status specified.
The problem is that client side I cannot retrieve nothing, neither the exception or the exception message.

I'm surely doing it wrongly, but I haven't find any written explanation on how managing exception.

Could someone give me some hints to the right way???
    
      
I think you can do the following in your catch block :
throw new ResourceException(Status.SERVER_ERROR_INTERNAL, e);
If it is not enough, try to extend StatusService class. More info in 
this thread 
http://restlet.markmail.org/message/ptesti33kkk5bksv?q=StatusService
Hope it help.
Regards,
Laurent.

  
    
Thanks

---------------
@Post
public void createUser(Representation entity) {
try {
// Parse the given representation and retrieve pairs of  
// "name=value" tokens.  
Form form = new Form(entity);  
String userId=form.getFirstValue("userId");  

myApplication.createUser(userId);

setStatus(Status.SUCCESS_CREATED, "Created User: " + userId);  
} catch(Throwable e) {

e.printStackTrace();
setStatus(Status.SERVER_ERROR_INTERNAL, e, e.getMessage());  

} 
}
    
      
    

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2381361

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2384451

  

--

Patrizio Munzi
Product Specialist
Viale Bruno Buozzi, 19 - 00197 Roma (Italy)
tel: +39 06 4543 3540
fax: +39 06 4543 3587
mobile: +39 393 7195 164
mail: [hidden email]
web: http://www.eris4.com
skype: eris4_munzi


--

Patrizio Munzi
Product Specialist
Viale Bruno Buozzi, 19 - 00197 Roma (Italy)
tel: +39 06 4543 3540
fax: +39 06 4543 3587
mobile: +39 393 7195 164
mail: [hidden email]
web: http://www.eris4.com
skype: eris4_munzi


--

Patrizio Munzi
Product Specialist
Viale Bruno Buozzi, 19 - 00197 Roma (Italy)
tel: +39 06 4543 3540
fax: +39 06 4543 3587
mobile: +39 393 7195 164
mail: [hidden email]
web: http://www.eris4.com
skype: eris4_munzi




jlouvel

RE: problem returning a response status

Reply Threaded More More options
Print post
Permalink
Some javascript/style in this post has been disabled (why?)

Hi Patrizio,

 

We try to reply to all messages in this list (see archives). We just can guarantee the order and the delay…

 

If you need timely assistance, you can consider our professional technical support offer:

http://www.noelios.com/products/support

 

I know that the Servlet API is tricky about this point. I would need to debug this to be sure it is a bug on our side. Could you send us a small application reproducing the issue?

 

Best regards,
Jerome Louvel
--
Restlet ~ Founder and Lead developer ~ http://www.restlet.org
Noelios Technologies ~ Co-founder ~
http://www.noelios.com

 

 

 

De : Patrizio Munzi [mailto:[hidden email]]
Envoyé : mardi 29 septembre 2009 10:32
À : [hidden email]
Objet : Re: problem returning a response status

 

May I have a feedback at least...??

Please.

Patrizio Munzi wrote:

Isn't anybody interested in this??
Restlet developers...??

I think it should be solved..

Thanks

Patrizio Munzi wrote:

Hi everybody,

I think there's a bug or at least something strange in ResourceException management.
The getDescription method works only if I run my application in a stand-alone server.
It instead doesn't work if I run in a servlet container (tomcat 5.5).

I'm throwing the following exception server-side:
----------------------------------------------
        } catch(Throwable e) {
            throw new ResourceException(Status.SERVER_ERROR_INTERNAL, e.getMessage, e);
       }
----------------------------------------------


And here's my client code:
----------------------------------------------
        try {
            Form form = new Form(); 
            form.add("userId", userId); 
            Representation userRepresentation = form.getWebRepresentation();

            Request createUserRequest = new Request(Method.POST, createUrl);

            createUserRequest.setEntity(userRepresentation);
            Response response = client.handle(createUserRequest);
            resultStatus = response.getStatus();
        } catch (Throwable t) {
            System.err.println("Exception in creating User: " + userId + ". Exception: " + t);
        }       
        if (resultStatus.isSuccess()) { 
            System.out.println("Created User: " + userId + ". Status: " + resultStatus.getName() + " - Description: " + resultStatus.getDescription());
        }
        else {
            System.err.println("Error in creating User: " + userId + ". Status: " + resultStatus.getName() + " - Description: " + resultStatus.getDescription());
        }
----------------------------------------------


II the application runs in a servlet container I get the following message client side:

Error in creating User: TestUser. Status: Internal Server Error - Description: OK

instead in a stand alone server I get the right description:

Error in creating User: TestUser. Status: Internal Server Error - Description: Test Exception

Has anyone got any idea if it's a bug or I'm doing something wrong????

Thanks

Jerome Louvel wrote:

Hi all,
 
Regarding the propagation of exceptions on the client-side, I've got some plans there:
 
"Add exception conversion to ConverterService"
http://restlet.tigris.org/issues/show_bug.cgi?id=878
 
Best regards,
Jerome Louvel
--
Restlet ~ Founder and Lead developer ~ http://www.restlet.org
Noelios Technologies ~ Co-founder ~ http://www.noelios.com
 
 
-----Message d'origine-----
De : Thierry Boileau [[hidden email]] 
Envoyé : vendredi 7 août 2009 18:02
À : [hidden email]
Objet : Re: problem returning a response status
 
Hello Patrizio  and Laurent,
 
 
you're right Laurent. I notice also there is a lack of documentation 
about this that needs to be addressed.
 
best regards,
Thierry Boileau
 
  
Hello,
Patrizio Munzi a écrit :
  
    
I'm trying to make work the following simple exception handling.
I just want to return the status specified.
The problem is that client side I cannot retrieve nothing, neither the exception or the exception message.
 
I'm surely doing it wrongly, but I haven't find any written explanation on how managing exception.
 
Could someone give me some hints to the right way???
    
      
I think you can do the following in your catch block :
throw new ResourceException(Status.SERVER_ERROR_INTERNAL, e);
If it is not enough, try to extend StatusService class. More info in 
this thread 
http://restlet.markmail.org/message/ptesti33kkk5bksv?q=StatusService
Hope it help.
Regards,
Laurent.
 
  
    
Thanks
 
---------------
@Post
public void createUser(Representation entity) {
try {
// Parse the given representation and retrieve pairs of  
// "name=value" tokens.  
Form form = new Form(entity);  
String userId=form.getFirstValue("userId");  
 
myApplication.createUser(userId);
 
setStatus(Status.SUCCESS_CREATED, "Created User: " + userId);  
} catch(Throwable e) {
 
e.printStackTrace();
setStatus(Status.SERVER_ERROR_INTERNAL, e, e.getMessage());  
 
} 
}
    
      
 
    
 
------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2381361
 
------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2384451
 
  

 

--

Patrizio Munzi
Product Specialist
Viale Bruno Buozzi, 19 - 00197 Roma (Italy)
tel: +39 06 4543 3540
fax: +39 06 4543 3587
mobile: +39 393 7195 164
mail: [hidden email]
web: http://www.eris4.com
skype: eris4_munzi

 

--

Patrizio Munzi
Product Specialist
Viale Bruno Buozzi, 19 - 00197 Roma (Italy)
tel: +39 06 4543 3540
fax: +39 06 4543 3587
mobile: +39 393 7195 164
mail: [hidden email]
web: http://www.eris4.com
skype: eris4_munzi

 

--

Patrizio Munzi
Product Specialist
Viale Bruno Buozzi, 19 - 00197 Roma (Italy)
tel: +39 06 4543 3540
fax: +39 06 4543 3587
mobile: +39 393 7195 164
mail: [hidden email]
web: http://www.eris4.com
skype: eris4_munzi


patrizio.munzi

Re: problem returning a response status

Reply Threaded More More options
Print post
Permalink
In reply to this post by patrizio.munzi
Some javascript/style in this post has been disabled (why?)
Jerome,

never experienced this problem...??

Thanks

Patrizio Munzi wrote:
Hi everybody,

I think there's a bug or at least something strange in ResourceException management.
The getDescription method works only if I run my application in a stand-alone server.
It instead doesn't work if I run in a servlet container (tomcat 5.5).

I'm throwing the following exception server-side:
----------------------------------------------
        } catch(Throwable e) {
            throw new ResourceException(Status.SERVER_ERROR_INTERNAL, e.getMessage, e);
       }
----------------------------------------------


And here's my client code:
----------------------------------------------
        try {
            Form form = new Form(); 
            form.add("userId", userId); 
            Representation userRepresentation = form.getWebRepresentation();

            Request createUserRequest = new Request(Method.POST, createUrl);

            createUserRequest.setEntity(userRepresentation);
            Response response = client.handle(createUserRequest);
            resultStatus = response.getStatus();
        } catch (Throwable t) {
            System.err.println("Exception in creating User: " + userId + ". Exception: " + t);
        }       
        if (resultStatus.isSuccess()) { 
            System.out.println("Created User: " + userId + ". Status: " + resultStatus.getName() + " - Description: " + resultStatus.getDescription());
        }
        else {
            System.err.println("Error in creating User: " + userId + ". Status: " + resultStatus.getName() + " - Description: " + resultStatus.getDescription());
        }
----------------------------------------------


II the application runs in a servlet container I get the following message client side:

Error in creating User: TestUser. Status: Internal Server Error - Description: OK

instead in a stand alone server I get the right description:

Error in creating User: TestUser. Status: Internal Server Error - Description: Test Exception

Has anyone got any idea if it's a bug or I'm doing something wrong????

Thanks

Jerome Louvel wrote:
Hi all,

Regarding the propagation of exceptions on the client-side, I've got some plans there:

"Add exception conversion to ConverterService"
http://restlet.tigris.org/issues/show_bug.cgi?id=878

Best regards,
Jerome Louvel
--
Restlet ~ Founder and Lead developer ~ http://www.restlet.org
Noelios Technologies ~ Co-founder ~ http://www.noelios.com


-----Message d'origine-----
De : Thierry Boileau [[hidden email]] 
Envoyé : vendredi 7 août 2009 18:02
À : [hidden email]
Objet : Re: problem returning a response status

Hello Patrizio  and Laurent,


you're right Laurent. I notice also there is a lack of documentation 
about this that needs to be addressed.

best regards,
Thierry Boileau

  
Hello,
Patrizio Munzi a écrit :
  
    
I'm trying to make work the following simple exception handling.
I just want to return the status specified.
The problem is that client side I cannot retrieve nothing, neither the exception or the exception message.

I'm surely doing it wrongly, but I haven't find any written explanation on how managing exception.

Could someone give me some hints to the right way???
    
      
I think you can do the following in your catch block :
throw new ResourceException(Status.SERVER_ERROR_INTERNAL, e);
If it is not enough, try to extend StatusService class. More info in 
this thread 
http://restlet.markmail.org/message/ptesti33kkk5bksv?q=StatusService
Hope it help.
Regards,
Laurent.

  
    
Thanks

---------------
@Post
public void createUser(Representation entity) {
try {
// Parse the given representation and retrieve pairs of  
// "name=value" tokens.  
Form form = new Form(entity);  
String userId=form.getFirstValue("userId");  

myApplication.createUser(userId);

setStatus(Status.SUCCESS_CREATED, "Created User: " + userId);  
} catch(Throwable e) {

e.printStackTrace();
setStatus(Status.SERVER_ERROR_INTERNAL, e, e.getMessage());  

} 
}
    
      

    

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2381361

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2384451

  

--

Patrizio Munzi
Product Specialist
Viale Bruno Buozzi, 19 - 00197 Roma (Italy)
tel: +39 06 4543 3540
fax: +39 06 4543 3587
mobile: +39 393 7195 164
mail: [hidden email]
web: http://www.eris4.com
skype: eris4_munzi


--

Patrizio Munzi
Product Specialist
Viale Bruno Buozzi, 19 - 00197 Roma (Italy)
tel: +39 06 4543 3540
fax: +39 06 4543 3587
mobile: +39 393 7195 164
mail: [hidden email]
web: http://www.eris4.com
skype: eris4_munzi



jlouvel

RE: problem returning a response status

Reply Threaded More More options
Print post
Permalink
Some javascript/style in this post has been disabled (why?)

Hi Patrizio,

 

Servlet containers put some constraints in the way reason phrases are reported to the client. Basically, they don’t allow us to set the HTTP reason phrase.

 

They only give us a way (via HttpServletResponse# sendError(int sc, String msg)  method) to include the Status#reasonPhrase property in the body of the HTML error page automatically generated by the Servlet container…

 

Best regards,
Jerome Louvel
--
Restlet ~ Founder and Lead developer ~ http://www.restlet.org
Noelios Technologies ~ Co-founder ~
http://www.noelios.com

 

 

De : Patrizio Munzi [mailto:[hidden email]]
Envoyé : mardi 27 octobre 2009 09:57
À : [hidden email]
Objet : Re: problem returning a response status

 

Jerome,

never experienced this problem...??

Thanks

Patrizio Munzi wrote:

Hi everybody,

I think there's a bug or at least something strange in ResourceException management.
The getDescription method works only if I run my application in a stand-alone server.
It instead doesn't work if I run in a servlet container (tomcat 5.5).

I'm throwing the following exception server-side:
----------------------------------------------
        } catch(Throwable e) {
            throw new ResourceException(Status.SERVER_ERROR_INTERNAL, e.getMessage, e);
       }
----------------------------------------------


And here's my client code:
----------------------------------------------
        try {
            Form form = new Form(); 
            form.add("userId", userId); 
            Representation userRepresentation = form.getWebRepresentation();

            Request createUserRequest = new Request(Method.POST, createUrl);

            createUserRequest.setEntity(userRepresentation);
            Response response = client.handle(createUserRequest);
            resultStatus = response.getStatus();
        } catch (Throwable t) {
            System.err.println("Exception in creating User: " + userId + ". Exception: " + t);
        }       
        if (resultStatus.isSuccess()) { 
            System.out.println("Created User: " + userId + ". Status: " + resultStatus.getName() + " - Description: " + resultStatus.getDescription());
        }
        else {
            System.err.println("Error in creating User: " + userId + ". Status: " + resultStatus.getName() + " - Description: " + resultStatus.getDescription());
        }
----------------------------------------------


II the application runs in a servlet container I get the following message client side:

Error in creating User: TestUser. Status: Internal Server Error - Description: OK

instead in a stand alone server I get the right description:

Error in creating User: TestUser. Status: Internal Server Error - Description: Test Exception

Has anyone got any idea if it's a bug or I'm doing something wrong????

Thanks

Jerome Louvel wrote:

Hi all,
 
Regarding the propagation of exceptions on the client-side, I've got some plans there:
 
"Add exception conversion to ConverterService"
http://restlet.tigris.org/issues/show_bug.cgi?id=878
 
Best regards,
Jerome Louvel
--
Restlet ~ Founder and Lead developer ~ http://www.restlet.org
Noelios Technologies ~ Co-founder ~ http://www.noelios.com
 
 
-----Message d'origine-----
De : Thierry Boileau [[hidden email]] 
Envoyé : vendredi 7 août 2009 18:02
À : [hidden email]
Objet : Re: problem returning a response status
 
Hello Patrizio  and Laurent,
 
 
you're right Laurent. I notice also there is a lack of documentation 
about this that needs to be addressed.
 
best regards,
Thierry Boileau
 
  
Hello,
Patrizio Munzi a écrit :
  
    
I'm trying to make work the following simple exception handling.
I just want to return the status specified.
The problem is that client side I cannot retrieve nothing, neither the exception or the exception message.
 
I'm surely doing it wrongly, but I haven't find any written explanation on how managing exception.
 
Could someone give me some hints to the right way???
    
      
I think you can do the following in your catch block :
throw new ResourceException(Status.SERVER_ERROR_INTERNAL, e);
If it is not enough, try to extend StatusService class. More info in 
this thread 
http://restlet.markmail.org/message/ptesti33kkk5bksv?q=StatusService
Hope it help.
Regards,
Laurent.
 
  
    
Thanks
 
---------------
@Post
public void createUser(Representation entity) {
try {
// Parse the given representation and retrieve pairs of  
// "name=value" tokens.  
Form form = new Form(entity);  
String userId=form.getFirstValue("userId");  
 
myApplication.createUser(userId);
 
setStatus(Status.SUCCESS_CREATED, "Created User: " + userId);  
} catch(Throwable e) {
 
e.printStackTrace();
setStatus(Status.SERVER_ERROR_INTERNAL, e, e.getMessage());  
 
} 
}
    
      
 
 
    
 
------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2381361
 
------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2384451
 
  

 

--

Patrizio Munzi
Product Specialist
Viale Bruno Buozzi, 19 - 00197 Roma (Italy)
tel: +39 06 4543 3540
fax: +39 06 4543 3587
mobile: +39 393 7195 164
mail: [hidden email]
web: http://www.eris4.com
skype: eris4_munzi

 

--

Patrizio Munzi
Product Specialist
Viale Bruno Buozzi, 19 - 00197 Roma (Italy)
tel: +39 06 4543 3540
fax: +39 06 4543 3587
mobile: +39 393 7195 164
mail: [hidden email]
web: http://www.eris4.com
skype: eris4_munzi


patrizio.munzi

Re: problem returning a response status

Reply Threaded More More options
Print post
Permalink
In reply to this post by patrizio.munzi
Some javascript/style in this post has been disabled (why?)
Up!

Patrizio Munzi wrote:
Jerome,

never experienced this problem...??

Thanks

Patrizio Munzi wrote:
Hi everybody,

I think there's a bug or at least something strange in ResourceException management.
The getDescription method works only if I run my application in a stand-alone server.
It instead doesn't work if I run in a servlet container (tomcat 5.5).

I'm throwing the following exception server-side:
----------------------------------------------
        } catch(Throwable e) {
            throw new ResourceException(Status.SERVER_ERROR_INTERNAL, e.getMessage, e);
       }
----------------------------------------------


And here's my client code:
----------------------------------------------
        try {
            Form form = new Form(); 
            form.add("userId", userId); 
            Representation userRepresentation = form.getWebRepresentation();

            Request createUserRequest = new Request(Method.POST, createUrl);

            createUserRequest.setEntity(userRepresentation);
            Response response = client.handle(createUserRequest);
            resultStatus = response.getStatus();
        } catch (Throwable t) {
            System.err.println("Exception in creating User: " + userId + ". Exception: " + t);
        }       
        if (resultStatus.isSuccess()) { 
            System.out.println("Created User: " + userId + ". Status: " + resultStatus.getName() + " - Description: " + resultStatus.getDescription());
        }
        else {
            System.err.println("Error in creating User: " + userId + ". Status: " + resultStatus.getName() + " - Description: " + resultStatus.getDescription());
        }
----------------------------------------------


II the application runs in a servlet container I get the following message client side:

Error in creating User: TestUser. Status: Internal Server Error - Description: OK

instead in a stand alone server I get the right description:

Error in creating User: TestUser. Status: Internal Server Error - Description: Test Exception

Has anyone got any idea if it's a bug or I'm doing something wrong????

Thanks

Jerome Louvel wrote:
Hi all,

Regarding the propagation of exceptions on the client-side, I've got some plans there:

"Add exception conversion to ConverterService"
http://restlet.tigris.org/issues/show_bug.cgi?id=878

Best regards,
Jerome Louvel
--
Restlet ~ Founder and Lead developer ~ http://www.restlet.org
Noelios Technologies ~ Co-founder ~ http://www.noelios.com


-----Message d'origine-----
De : Thierry Boileau [[hidden email]] 
Envoyé : vendredi 7 août 2009 18:02
À : [hidden email]
Objet : Re: problem returning a response status

Hello Patrizio  and Laurent,


you're right Laurent. I notice also there is a lack of documentation 
about this that needs to be addressed.

best regards,
Thierry Boileau

  
Hello,
Patrizio Munzi a écrit :
  
    
I'm trying to make work the following simple exception handling.
I just want to return the status specified.
The problem is that client side I cannot retrieve nothing, neither the exception or the exception message.

I'm surely doing it wrongly, but I haven't find any written explanation on how managing exception.

Could someone give me some hints to the right way???
    
      
I think you can do the following in your catch block :
throw new ResourceException(Status.SERVER_ERROR_INTERNAL, e);
If it is not enough, try to extend StatusService class. More info in 
this thread 
http://restlet.markmail.org/message/ptesti33kkk5bksv?q=StatusService
Hope it help.
Regards,
Laurent.

  
    
Thanks

---------------
@Post
public void createUser(Representation entity) {
try {
// Parse the given representation and retrieve pairs of  
// "name=value" tokens.  
Form form = new Form(entity);  
String userId=form.getFirstValue("userId");  

myApplication.createUser(userId);

setStatus(Status.SUCCESS_CREATED, "Created User: " + userId);  
} catch(Throwable e) {

e.printStackTrace();
setStatus(Status.SERVER_ERROR_INTERNAL, e, e.getMessage());  

} 
}
    
      
    

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2381361

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2384451

  

--

Patrizio Munzi
Product Specialist
Viale Bruno Buozzi, 19 - 00197 Roma (Italy)
tel: +39 06 4543 3540
fax: +39 06 4543 3587
mobile: +39 393 7195 164
mail: [hidden email]
web: http://www.eris4.com
skype: eris4_munzi


--

Patrizio Munzi
Product Specialist
Viale Bruno Buozzi, 19 - 00197 Roma (Italy)
tel: +39 06 4543 3540
fax: +39 06 4543 3587
mobile: +39 393 7195 164
mail: [hidden email]
web: http://www.eris4.com
skype: eris4_munzi


--

Patrizio Munzi
Product Specialist
Viale Bruno Buozzi, 19 - 00197 Roma (Italy)
tel: +39 06 4543 3540
fax: +39 06 4543 3587
mobile: +39 393 7195 164
mail: [hidden email]
web: http://www.eris4.com
skype: eris4_munzi




jlouvel

RE: problem returning a response status

Reply Threaded More More options
Print post
Permalink
Some javascript/style in this post has been disabled (why?)

Hi Patrizio,

 

I’ve already replied to your question here:

http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2413739

 

I hope that clarifies why you encounter this issue.

 

Best regards,
Jerome Louvel
--
Restlet ~ Founder and Lead developer ~ http://www.restlet.org
Noelios Technologies ~ Co-founder ~
http://www.noelios.com

 

 

 

 

De : Patrizio Munzi [mailto:[hidden email]]
Envoyé : vendredi 6 novembre 2009 17:33
À : [hidden email]
Objet : Re: problem returning a response status

 

Up!

Patrizio Munzi wrote:

Jerome,

never experienced this problem...??

Thanks

Patrizio Munzi wrote:

Hi everybody,

I think there's a bug or at least something strange in ResourceException management.
The getDescription method works only if I run my application in a stand-alone server.
It instead doesn't work if I run in a servlet container (tomcat 5.5).

I'm throwing the following exception server-side:
----------------------------------------------
        } catch(Throwable e) {
            throw new ResourceException(Status.SERVER_ERROR_INTERNAL, e.getMessage, e);
       }
----------------------------------------------


And here's my client code:
----------------------------------------------
        try {
            Form form = new Form(); 
            form.add("userId", userId); 
            Representation userRepresentation = form.getWebRepresentation();

            Request createUserRequest = new Request(Method.POST, createUrl);

            createUserRequest.setEntity(userRepresentation);
            Response response = client.handle(createUserRequest);
            resultStatus = response.getStatus();
        } catch (Throwable t) {
            System.err.println("Exception in creating User: " + userId + ". Exception: " + t);
        }       
        if (resultStatus.isSuccess()) { 
            System.out.println("Created User: " + userId + ". Status: " + resultStatus.getName() + " - Description: " + resultStatus.getDescription());
        }
        else {
            System.err.println("Error in creating User: " + userId + ". Status: " + resultStatus.getName() + " - Description: " + resultStatus.getDescription());
        }
----------------------------------------------


II the application runs in a servlet container I get the following message client side:

Error in creating User: TestUser. Status: Internal Server Error - Description: OK

instead in a stand alone server I get the right description:

Error in creating User: TestUser. Status: Internal Server Error - Description: Test Exception

Has anyone got any idea if it's a bug or I'm doing something wrong????

Thanks

Jerome Louvel wrote:

Hi all,
 
Regarding the propagation of exceptions on the client-side, I've got some plans there:
 
"Add exception conversion to ConverterService"
http://restlet.tigris.org/issues/show_bug.cgi?id=878
 
Best regards,
Jerome Louvel
--
Restlet ~ Founder and Lead developer ~ http://www.restlet.org
Noelios Technologies ~ Co-founder ~ http://www.noelios.com
 
 
-----Message d'origine-----
De : Thierry Boileau [[hidden email]] 
Envoyé : vendredi 7 août 2009 18:02
À : [hidden email]
Objet : Re: problem returning a response status
 
Hello Patrizio  and Laurent,
 
 
you're right Laurent. I notice also there is a lack of documentation 
about this that needs to be addressed.
 
best regards,
Thierry Boileau
 
  
Hello,
Patrizio Munzi a écrit :
  
    
I'm trying to make work the following simple exception handling.
I just want to return the status specified.
The problem is that client side I cannot retrieve nothing, neither the exception or the exception message.
 
I'm surely doing it wrongly, but I haven't find any written explanation on how managing exception.
 
Could someone give me some hints to the right way???
    
      
I think you can do the following in your catch block :
throw new ResourceException(Status.SERVER_ERROR_INTERNAL, e);
If it is not enough, try to extend StatusService class. More info in 
this thread 
http://restlet.markmail.org/message/ptesti33kkk5bksv?q=StatusService
Hope it help.
Regards,
Laurent.
 
  
    
Thanks
 
---------------
@Post
public void createUser(Representation entity) {
try {
// Parse the given representation and retrieve pairs of  
// "name=value" tokens.  
Form form = new Form(entity);  
String userId=form.getFirstValue("userId");  
 
myApplication.createUser(userId);
 
setStatus(Status.SUCCESS_CREATED, "Created User: " + userId);  
} catch(Throwable e) {
 
e.printStackTrace();
setStatus(Status.SERVER_ERROR_INTERNAL, e, e.getMessage());  
 
} 
}
    
      
 
    
 
------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2381361
 
------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2384451
 
  

 

--

Patrizio Munzi
Product Specialist
Viale Bruno Buozzi, 19 - 00197 Roma (Italy)
tel: +39 06 4543 3540
fax: +39 06 4543 3587
mobile: +39 393 7195 164
mail: [hidden email]
web: http://www.eris4.com
skype: eris4_munzi

 

--

Patrizio Munzi
Product Specialist
Viale Bruno Buozzi, 19 - 00197 Roma (Italy)
tel: +39 06 4543 3540
fax: +39 06 4543 3587
mobile: +39 393 7195 164
mail: [hidden email]
web: http://www.eris4.com
skype: eris4_munzi

 

--

Patrizio Munzi
Product Specialist
Viale Bruno Buozzi, 19 - 00197 Roma (Italy)
tel: +39 06 4543 3540
fax: +39 06 4543 3587
mobile: +39 393 7195 164
mail: [hidden email]
web: http://www.eris4.com
skype: eris4_munzi


patrizio.munzi

Re: problem returning a response status

Reply Threaded More More options
Print post
Permalink
Some javascript/style in this post has been disabled (why?)
Thanks Jerome,

Sorry but I missed that mail.

Regards.

Jerome Louvel wrote:

Hi Patrizio,

 

I’ve already replied to your question here:

http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2413739

 

I hope that clarifies why you encounter this issue.

 

Best regards,
Jerome Louvel
--
Restlet ~ Founder and Lead developer ~ http://www.restlet.org
Noelios Technologies ~ Co-founder ~
http://www.noelios.com

 

 

 

 

De : Patrizio Munzi [[hidden email]]
Envoyé : vendredi 6 novembre 2009 17:33
À : [hidden email]
Objet : Re: problem returning a response status

 

Up!

Patrizio Munzi wrote:

Jerome,

never experienced this problem...??

Thanks

Patrizio Munzi wrote:

Hi everybody,

I think there's a bug or at least something strange in ResourceException management.
The getDescription method works only if I run my application in a stand-alone server.
It instead doesn't work if I run in a servlet container (tomcat 5.5).

I'm throwing the following exception server-side:
----------------------------------------------
        } catch(Throwable e) {
            throw new ResourceException(Status.SERVER_ERROR_INTERNAL, e.getMessage, e);
       }
----------------------------------------------


And here's my client code:
----------------------------------------------
        try {
            Form form = new Form(); 
            form.add("userId", userId); 
            Representation userRepresentation = form.getWebRepresentation();

            Request createUserRequest = new Request(Method.POST, createUrl);

            createUserRequest.setEntity(userRepresentation);
            Response response = client.handle(createUserRequest);
            resultStatus = response.getStatus();
        } catch (Throwable t) {
            System.err.println("Exception in creating User: " + userId + ". Exception: " + t);
        }       
        if (resultStatus.isSuccess()) { 
            System.out.println("Created User: " + userId + ". Status: " + resultStatus.getName() + " - Description: " + resultStatus.getDescription());
        }
        else {
            System.err.println("Error in creating User: " + userId + ". Status: " + resultStatus.getName() + " - Description: " + resultStatus.getDescription());
        }
----------------------------------------------


II the application runs in a servlet container I get the following message client side:

Error in creating User: TestUser. Status: Internal Server Error - Description: OK

instead in a stand alone server I get the right description:

Error in creating User: TestUser. Status: Internal Server Error - Description: Test Exception

Has anyone got any idea if it's a bug or I'm doing something wrong????

Thanks

Jerome Louvel wrote:

Hi all,
 
Regarding the propagation of exceptions on the client-side, I've got some plans there:
 
"Add exception conversion to ConverterService"
http://restlet.tigris.org/issues/show_bug.cgi?id=878
 
Best regards,
Jerome Louvel
--
Restlet ~ Founder and Lead developer ~ http://www.restlet.org
Noelios Technologies ~ Co-founder ~ http://www.noelios.com
 
 
-----Message d'origine-----
De : Thierry Boileau [[hidden email]] 
Envoyé : vendredi 7 août 2009 18:02
À : [hidden email]
Objet : Re: problem returning a response status
 
Hello Patrizio  and Laurent,
 
 
you're right Laurent. I notice also there is a lack of documentation 
about this that needs to be addressed.
 
best regards,
Thierry Boileau
 
  
Hello,
Patrizio Munzi a écrit :
  
    
I'm trying to make work the following simple exception handling.
I just want to return the status specified.
The problem is that client side I cannot retrieve nothing, neither the exception or the exception message.
 
I'm surely doing it wrongly, but I haven't find any written explanation on how managing exception.
 
Could someone give me some hints to the right way???
    
      
I think you can do the following in your catch block :
throw new ResourceException(Status.SERVER_ERROR_INTERNAL, e);
If it is not enough, try to extend StatusService class. More info in 
this thread 
http://restlet.markmail.org/message/ptesti33kkk5bksv?q=StatusService
Hope it help.
Regards,
Laurent.
 
  
    
Thanks
 
---------------
@Post
public void createUser(Representation entity) {
try {
// Parse the given representation and retrieve pairs of  
// "name=value" tokens.  
Form form = new Form(entity);  
String userId=form.getFirstValue("userId");  
 
myApplication.createUser(userId);
 
setStatus(Status.SUCCESS_CREATED, "Created User: " + userId);  
} catch(Throwable e) {
 
e.printStackTrace();
setStatus(Status.SERVER_ERROR_INTERNAL, e, e.getMessage());  
 
} 
}
    
      
 
    
 
------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2381361
 
------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2384451
 
  

 

--

Patrizio Munzi
Product Specialist
Viale Bruno Buozzi, 19 - 00197 Roma (Italy)
tel: +39 06 4543 3540
fax: +39 06 4543 3587
mobile: +39 393 7195 164
mail: [hidden email]
web: http://www.eris4.com
skype: eris4_munzi

 

--

Patrizio Munzi
Product Specialist
Viale Bruno Buozzi, 19 - 00197 Roma (Italy)
tel: +39 06 4543 3540
fax: +39 06 4543 3587
mobile: +39 393 7195 164
mail: [hidden email]
web: http://www.eris4.com
skype: eris4_munzi

 

--

Patrizio Munzi
Product Specialist
Viale Bruno Buozzi, 19 - 00197 Roma (Italy)
tel: +39 06 4543 3540
fax: +39 06 4543 3587
mobile: +39 393 7195 164
mail: [hidden email]
web: http://www.eris4.com
skype: eris4_munzi


--

Patrizio Munzi
Product Specialist
Viale Bruno Buozzi, 19 - 00197 Roma (Italy)
tel: +39 06 4543 3540
fax: +39 06 4543 3587
mobile: +39 393 7195 164
mail: [hidden email]
web: http://www.eris4.com
skype: eris4_munzi