Question
· Sep 1, 2016

[Java Gateway] How to interprete %Status of COS in Java side

I fire a call of COS method through Java gateway and get the return value whose type is %Status in COS.
What is the corresponding class for %Status in Java side? Any existing utility to help me parse this object so I could know this COS call finish with errors or not.

Discussion (3)0
Log in or sign up to continue

I only know what to use on the COS side; you can use the %SYSTEM.Status class with methods IsOK, IsError, GetErrorText, GetErrorCodes, like this:

s returnStatus = ...code that returns %Status...

s isOK = ##class(%SYSTEM.Status).IsOK(returnStatus)

There is a shortcut:

s isOK = $system.Status.IsOK(returnStatus)

I find .GetErrorText(returnStatus) and .DisplayError(returnStatus) methods to be quite useful when I want to display the error text in an alert window or on the screen (respectively).

See the class reference for more methods.

I don't know of a utility on the Java side;  that would be nice to know. Perhaps you can call out to COS again to parse it and return a Java type.  However, the first character of a %Status is always  a 1 if it's OK, and a 0 if it's an error.

Is this what you were looking for?

Thanks,

Laura

Ah, so you need to map the %SYSTEM.Status class from cache to a Java object.  I've never done that.  Did the "Java Proxy Class Mapping" have anything helpful?

http://docs.intersystems.com/latest/csp/docbook/DocBook.UI.Page.cls?KEY=...

and

http://docs.intersystems.com/latest/csp/docbook/DocBook.UI.Page.cls?KEY=...

I'm thinking you might have to create your own Status class that extens %Status; like creating your own exception class in Java. Then you can edit your Status class so that when compiled it will create a Java class. 

Sounds fun. Let me know if this works for you.