Returning custom error messages in ActionWebService

I want to return my own error messages from an API instead of letting
the client see the stack trace. I’m returning a custom structure so I
guess I could just put a member in that structure for the error
message, although that seems like kind of a hack. Any suggestions?

Chris

I answered my own question sort of. I just created a top level struct
that I wrap everything else into that has members for error messags,
then make sure I have a rescue clause at the end of every method.

On 7/29/06, snacktime [email protected] wrote:

I answered my own question sort of. I just created a top level struct
that I wrap everything else into that has members for error messags,
then make sure I have a rescue clause at the end of every method.

Ok I spoke too soon. That works in the api methods but not in the
invocation filters. I could call the filter from each method but
that’s kind of a hack. The invocation filters will show part of the
stack trace if you return false, which just isn’t acceptable for a lot
of applications. Any ideas?

On 7/29/06, snacktime [email protected] wrote:

Ok after doing some investigating I found out you can set this:

MyController.web_service_exception_reporting = false

However when you do that then the exception message sent to the client
makes soap4r croak with this message. I have no idea if it’s a bug in
ActionWebService or soap4r.

/usr/local/lib/ruby/1.8/soap/mapping/mapping.rb:106:in
fault2exception': undefined method+’ for nil:NilClass
(NoMethodError)

It also just sends a generic error message instead of the custom
message I want returned to the client. Also, I can’t just call the
before_invocation filter from the api method because it does it’s
eager loading of associations before I can run my filter, and I happen
to be using a postgresql set search_path in the filter, which has to
be set before any other database queries.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs