Thowing errors and raising alerts
Hi InterSystems Community
We recently had an issue where we weren't able to parse a JSON HTTP request, but the issue went by unnoticed. We also did not have a trace of what the raw HTTP request was that we couldn't parse. I'm looking at improving our this by:
Tracing the raw request using $$$TRACE
Raising an alert which will hit our Ens.Alert router which will compose and send an email
I'm having an issue with consistently raising the alert (I've seen it raise an alert before, and then it wouldn't raise it again on a subsequent message), and also the error back does not really make sense. Here's our class that handles the raw request and passes it to our BusinessService Class (shortened for brevity):
{
ClassMethod EventNotification() As %Status
{
Set tSC=$$$OK $$$ThrowOnError(##class(Ens.Director).CreateBusinessService("EventBus_JsonHttp",.tBusinessService)) $$$ThrowOnError(tBusinessService.ProcessInput(%request, .tBusinessServiceOutput)) Return tSC
}
}
And our Business Service Class:
{
Method OnProcessInput(pInput As %Stream.GlobalCharacter, Output pOutput As %Stream.Object) As %Status
{
set rawRequest = pInput.Content.Read()
do pInput.Content.Rewind()
set tEventNotification = ##class(Phu.EventBus.Events.EventNotification).%New()
$$$ThrowOnError(tEventNotification.%JSONImport(pInput.Content))
$$$ThrowOnError(..SendRequestAsync("Router_EventBus",tEventNotification))
return $$$OK
}
}
Even with the production item setting "Alert on Error" set to true, this does not raise an error when I send in a badly formed request (typo in a property name). Also, the error back looks empty:
{
"errors": [
{
"code": "<Ens>ErrException",
"domain": "Ens",
"error": "ERROR <Ens>ErrException: -- logged as '-' number - @''",
"id": "EnsErrException",
"params": [
" -- ",
"-",
"- @''"
]
}
],
"summary": "ERROR <Ens>ErrException: -- logged as '-' number - @''"
}
Apologies for the really long post!