#1 2021-03-25 06:54:38

sakura
Member
From: Germany
Registered: 2018-02-21
Posts: 238
Website

HandleErrorAsRegularResult missing for ReturnsJson

Hi,

I'm kind of irritated already, that TRestServerUriContext decides to change my returned content as per default, when I have an error code, however, it really bugs me, that when using ReturnsJson, that there is no option, to suppress that behavior. Why would that be. We have established a pretty specific communication protocol within our system, to send data, states, etc.

Yes, we can convert to JSON every time manually and use Returns with HandleErrorAsRegularResult set to true, but why is it designed to force one to do it that way? Shouldn't the lib, as per standard, treat content returned as-is, rather than changing it in some circumstances?

Would it at least make sense, having an overloaded version of ReturnsJson with the HandleErrorAsRegularResult parameter available?

Regards,
Daniel

Offline

#2 2021-03-26 08:05:00

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,548
Website

Re: HandleErrorAsRegularResult missing for ReturnsJson

Fair enough.

I have added the HandleErrorAsRegularResult: boolean optional parameter to ReturnsJson().
Check https://github.com/synopse/mORMot2/comm … 3b61ff428f

Offline

#3 2021-03-26 08:24:20

sakura
Member
From: Germany
Registered: 2018-02-21
Posts: 238
Website

Re: HandleErrorAsRegularResult missing for ReturnsJson

Thanks, perfect :-)

Would you like such changes as pull request, or do you prefer to do them yourself?

Offline

#4 2021-03-26 09:51:16

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,548
Website

Re: HandleErrorAsRegularResult missing for ReturnsJson

Pull requests are always better I guess.

It makes more visibility to the modification, and also to the whole project.

Thanks for the feedback!

Offline

Board footer

Powered by FluxBB