Thanks for the response. Comments inline..
On Feb 20, 7:02 pm, "aaron smith" <
beingthexempl...@gmail.com> wrote:
> so you're just wondering about handling errors, not neccessarily mapping non
> AR objects?
I was asking about both...
>
> for error handling, there is an object called FaultObject, when used it
> triggers your fault handler in flash. You want to use this instead because
> of the fact that it triggers fault handlers.
>
> so you'd do something like;
>
> render :amf => FaultObject.new(1, "my error"); //1 is any code you want
>
> and in flash i believe it comes in faultCode and faultMessage /
> faultDetails. I can't remember off hand, but that's pretty much what you
> want.
Ok, i tried this, but i get back this monster object which includes a
stack trace. This stack trace also appears on the server-side which i
don't want. Also, it has a particular structure; i want to define my
own error object, not something pre-defined for me. Basically i want
to define my own class (as in the ServiceError example above) and
return that. It looks like i'll have to distinguish between the two
(or create a wrapper class) in the result handler.
>
> and just in case you want to map non-ar objects, you need to require the
> file in the rubyamf init.rb file (in the rubyamf plugins dir). So that the
> class is in memory and available at runtime. So your service error class
> mapping is correct, the class just needs to be required in that init file.
I do want to map non-AR objects, but adding it to init.rb did not
help, i was still getting the below:
From GetAccount result: (mx.messaging.messages::AcknowledgeMessage)#0
body = (Object)#1
code = 101
message = "object not found"
clientId = "dfa4d449-517e-0556-ee1c-d3d9f7e6b3d7"
correlationId = "9E2230A5-D462-2FA4-AB30-3DAFEA8E1A79"
destination = (null)
headers = (Object)#2
messageId = "eec4ce23-d61d-9f09-c52c-3397b0ebd1cf"
timestamp = NaN
timeToLive = 0
In other words, getting "Object" back instead of
com.pomodo.vo.ServiceErrorVO. HOWEVER, the client code wasn't actually
instantiating a ServiceErrorVO since i was just testing (ie, dumping
the contents of ResultEvent.message). When i added some client code
that instantiated a ServiceErrorVO from the result object, then it was
fine. Note that this worked fine w/o any require statement in init.rb.
Freaky.
Eg, this is my function that receives the result:
private function handleGetAccountResult(e:ResultEvent): void {
Debug.log( e.message ); // this prints out the above
// So if the below is commented out, then the above
says that i have an "Object" back. But if it's not, then i properly
get a "ServiceErrorVO" object.
//var error: ServiceErrorVO = ServiceErrorVO(e.result);
...
}