Login for more options
restSetResponse() requires the method to be returntype void
snippet in the docs:
You must set the returntype attribute of the function to void when a custom response is returned using the function restSetResponse.
Note that it says no such thing against the docs for the actual function (which would be the most sensible place to mention it), just in this devnet article. I have annotated the docs to point this out.
The Stackoverflow question makes a good point:
It works well, except that it forces you to set the function's returntype to "void". The problem with "void" is that whenever I throw an exception, it no longer returns the proper JSON error message.
And they're right. It's entirely reasonable that a method might only conditionally furnish its response via this restSetRespose(), and otherwise respond by returning stuff (be it an error in this case, or any other sort of response). It makes no sense to me that whether or not restSetResponse() works is based on the return type of the method.
My Hardware and Environment details:
|Platform(s)||Windows 7 64-bit|
|Found In Build||Final|
|Fixed In Build||287252|
10:37:55 AM GMT+00:00 Nov 1, 2016
Need to use restSetResponse with non-void function