Skip to content

Commit 34316ee

Browse files
committed
Better error handling
1 parent 2221776 commit 34316ee

File tree

4 files changed

+28
-8
lines changed

4 files changed

+28
-8
lines changed

isc/rabbitmq/Common.cls

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,23 @@ Method ConnectToRabbitMQ() As %Status
8383

8484
Try {
8585
Set ..API = ##class(isc.rabbitmq.API).%New(..JGW, ..Host, ..Port, user, pass, ..VirtualHost, ..Queue, $$$YES)
86-
} Catch ex {
87-
Set sc = $$$ADDSC(ex.AsStatus(),$g(%objlasterror))
86+
} Catch ex {
87+
Set sc = ..ExceptionToStatus(ex)
8888
}
8989

9090
Quit sc
9191
}
9292

93+
Method ExceptionToStatus(ex As %Exception.General) As %Status
94+
{
95+
#Dim sc As %Status
96+
If ((ex.Name="<ZJGTW>") && $d(%objlasterror)) {
97+
Set sc = %objlasterror
98+
} Else {
99+
Set sc = ex.AsStatus()
100+
}
101+
Quit sc
102+
}
103+
93104
}
94105

isc/rabbitmq/InboundAdapter.cls

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,22 @@ Method OnTask() As %Status
4444
#Dim messageList As %ListOfDataTypes
4545

4646
If ..BodyClass = "" {
47-
Set messageList = ..API.readMessageString()
47+
Try {
48+
Set messageList = ..API.readMessageString()
49+
} Catch ex {
50+
Set sc = ..ExceptionToStatus(ex)
51+
}
4852
} Else {
4953
#Dim tempStream As %Library.GlobalBinaryStream
5054
Set messageList = ##class(%ListOfDataTypes).%New()
5155
For i=1:1:15 Do messageList.Insert("")
52-
Set tempStream = ..API.readMessageStream(.messageList)
56+
Try {
57+
Set tempStream = ..API.readMessageStream(.messageList)
58+
} Catch ex {
59+
Set sc = ..ExceptionToStatus(ex)
60+
}
5361
}
62+
Quit:$$$ISERR(sc)
5463

5564
Set messageLength = messageList.GetAt(1)
5665
Set messageCount = messageList.GetAt(2)

isc/rabbitmq/OutboundAdapter.cls

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ Method SendMessage(message As %Stream.Object) As %Status
4141
Try {
4242
Do ..API.sendMessage(stream)
4343
} Catch ex {
44-
Set sc = ex.AsStatus()
44+
Set sc = ..ExceptionToStatus(ex)
4545
}
4646
Quit sc
4747
}
@@ -63,7 +63,7 @@ Method SendMessageToQueue(queue As %String, message As %Stream.Object) As %Statu
6363
Try {
6464
Do ..API.sendMessageToQueue(queue, stream)
6565
} Catch ex {
66-
Set sc = ex.AsStatus()
66+
Set sc = ..ExceptionToStatus(ex)
6767
}
6868
Quit sc
6969
}

isc/rabbitmq/Production.cls

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ XData ProductionDefinition
66
<Production Name="isc.rabbitmq.Production" TestingEnabled="true" LogGeneralTraceEvents="false">
77
<Description></Description>
88
<ActorPoolSize>2</ActorPoolSize>
9-
<Item Name="isc.rabbitmq.Service" Category="" ClassName="RabbitMQ.Service" PoolSize="1" Enabled="true" Foreground="false" Comment="" LogTraceEvents="true" Schedule="">
9+
<Item Name="isc.rabbitmq.Service" Category="" ClassName="isc.rabbitmq.Service" PoolSize="1" Enabled="true" Foreground="false" Comment="" LogTraceEvents="true" Schedule="">
1010
<Setting Target="Adapter" Name="JGService">EnsLib.JavaGateway.Service</Setting>
1111
<Setting Target="Adapter" Name="ClassPath">C:\InterSystems\RabbitMQjava.jar;C:\InterSystems\Java\amqp-client-5.7.2.jar</Setting>
1212
<Setting Target="Adapter" Name="Queue">hello</Setting>
@@ -20,7 +20,7 @@ XData ProductionDefinition
2020
<Setting Target="Host" Name="JavaHome">C:\Progra~1\Java\jdk1.8.0_121\</Setting>
2121
<Setting Target="Host" Name="ClassPath">C:\InterSystems\RabbitMQjava.jar;C:\InterSystems\Java\amqp-client-5.7.2.jar</Setting>
2222
</Item>
23-
<Item Name="isc.rabbitmq.Operation" Category="" ClassName="RabbitMQ.Operation" PoolSize="1" Enabled="true" Foreground="false" Comment="" LogTraceEvents="false" Schedule="">
23+
<Item Name="isc.rabbitmq.Operation" Category="" ClassName="isc.rabbitmq.Operation" PoolSize="1" Enabled="true" Foreground="false" Comment="" LogTraceEvents="false" Schedule="">
2424
<Setting Target="Adapter" Name="JGService">EnsLib.JavaGateway.Service</Setting>
2525
<Setting Target="Adapter" Name="Queue">hello</Setting>
2626
<Setting Target="Adapter" Name="ClassPath">C:\InterSystems\RabbitMQjava.jar;C:\InterSystems\Java\amqp-client-5.7.2.jar</Setting>

0 commit comments

Comments
 (0)