Hi
Some of our DOH requests are throwing custom errors back We need to serialise those custom errors into their native object and return them on the response. Essentially we have a message object which is built on top of apperror with extra properties.
is there any strategic location in the doh code which would allow me to do this?
I'm loathed to add error handling to each DOH endpoint as I prefer to catch our errors in a generic way.
Regards
Darren
Thanks Peter. After looking more closely at it, I think there's perhaps another way but I could be wrong on this and so I'll ask you.
The DOH is just using the standard Write() method of the EntityWriter. This has a special case for errors which I think is where my issue lies. In my webhandler (non DOH requests) I catch any error and just assign my error object to poReposne:Entity. This works fine.
With the DOH requests, the DOH is passing this error object to the entity writer and it calls writeError if its a progress.lang.error. I've not had to try to override this before but I've seen some of your other stuff on extending the jsonentitywriter but to be honest what I've done so far hasn't worked.
I've added to the registry in the handlerequest call. Cant I just write it to the entity in here or do I have to write a full blown json dump with byte counts to make this all work.
.
>The DOH is passing this to the entity writer and it calls writeError if its a progress.lang.error. I've not had to try to override this before but I've seen some of your other stuff on extending the jsonentitywriter >but to be honest what I've done so far hasn't worked.
It takles a couple of steps more than it should, because the JsonEntityWriter's WriteError() method is currently private (not protected). Instead of writing a MyJsonWriter that extend JsonEntityWriter, and overriding the WriteError method, you have to write a MyJsonWriter that uses the JsonEntityWriter, except for errors.
Something like
Class MyJsonWriter inherits MessageWriter:
Def private property mJsonWriter as JsonEntityWriter.
Method protected void WriteError(pError as Progress.Lang.Error):
End.
Method public void Write(pData as Progress.Lang.Object).
If valid-object(pData) and type-of(pData, P.L.Error) then Do:
WriteError(cast(pData, P.L.Error)).
Else
mJsonWriter:Write(pdata).
End method
End.
>The DOH is passing this to the entity writer and it calls writeError if its a progress.lang.error. I've not had to try to override this before but I've seen some of your other stuff on extending the jsonentitywriter >but to be honest what I've done so far hasn't worked.
It takles a couple of steps more than it should, because the JsonEntityWriter's WriteError() method is currently private (not protected). Instead of writing a MyJsonWriter that extend JsonEntityWriter, and overriding the WriteError method, you have to write a MyJsonWriter that uses the JsonEntityWriter, except for errors.
Something like this should work, but it's a little clunky