When an error has occurred, the return value is not 0. Instead, it is a %Status, and likely already contains the error information you need.
As to your actual question, finding (the id of) the response message header is not trivial. Ensemble Business Services have a %RequestHeader property from which you can take the CorrespondingMessageId, but unfortunately it is only populated if the call did not return an error status. It is still possible, though. You can use the id of the request body to find out what you need. It does need some SQL, though:
ClassMethod GetResponseHeaderId(RequestId As %String, Output sc As %Status) As %String
{
&sql(SELECT CorrespondingMessageId INTO :ResponseHeaderId
FROM Ens.MessageHeader
WHERE MessageBodyId = :RequestId)
If SQLCODE Set sc = $$$ERROR($$$SQLError, SQLCODE, $Get(%msg))
Set sc = $$$OK
Return ResponseHeaderId
}
With this helper method, you can open the response message header object. Assuming the request body is called CallReq:
Set Id = ..GetResponseHeaderId(CallReq.%Id(), .sc)
If 'sc Quit sc
Set RspHdr = ##class(Ens.MessageHeader).%OpenId(Id, , .sc)
If 'sc Quit sc
$$$LOGINFO("Response is an error: "_RspHdr.IsError)
HTH,
Gertjan.
Yes, something like that could work. I personally won't spend time on this, as I refuse to use the browser editors for this reason. I still use Studio for everything. It has it's annoyances, but at least it doesn't destroy my work for no good reason.
(This whole conversation astonishes me. We are talking about ideas and votes, like this is some minor inconvenience to some, instead of a prio 1 bug that InterSystems should fix yesterday.)
As far as I know, %File does not allow setting the file encoding. The %Stream.FileCharacter class Dmitry mentions does, but it's not called encoding. To use UTF-8, you need to set property TranslateTable to "UTF8" (no dash).