Article
· Mar 28, 2019 2m read
ObjectScript error handling snippets

ObjectScript has at least three ways of handling errors (status codes, exceptions, SQLCODE, etc.). Most of the system code uses statuses but exceptions are easier to handle for a number of reasons. Working with legacy code you spend some time translating between the different techniques. I use these snippets a lot for reference. Hopefully they're useful to others as well.

22 5
19 3.1K
Article
· Jul 8, 2020 7m read
Tips for debugging with %Status

Introduction

If you're solving complex problems in ObjectScript, you probably have a lot of code that works with %Status values. If you have interacted with persistent classes from an object perspective (%Save, %OpenId, etc.), you have almost certainly seen them. A %Status provides a wrapper around a localizable error message in InterSystems' platforms. An OK status ($$$OK) is just equal to 1, whereas a bad status ($$$ERROR(errorcode,arguments...)) is represented as a 0 followed by a space followed by a $ListBuild list with structured information about the error. $System.Status (see class reference) provides several handy APIs for working with %Status values; the class reference is helpful and I won't bother duplicating it here. There have been a few other useful articles/questions on the topic as well (see links at the end). My focus in this article will be on a few debugging tricks techniques rather than coding best practices (again, if you're looking for those, see links at the end).

15 7
11 1.7K
Article
· Aug 2, 2020 1m read
Application Errors Analytics

Hi Developers!

As you know the application errors live in ^ERRORS global. They appear there if you call:

d e.Log() 

in a Catch section of Try-Catch.

With @Robert Cemper's approach, you can now use SQL to examine it.

Inspired by Robert's module I introduced a simple IRIS Analytics module which shows these errors in a dashboard:

3 5
1 295
Article
· Oct 6, 2016 4m read
RESTful Exception Handling

A beginner’s guide to Exception Handling in RESTful web services. The article gives an example how the various error conditions during processing a service request can be handled.

We expect our client – server communication working in a flawless operational condition, running error free software. But we are prepared to handle exceptions. Are we? So far in the examples of the previous sessions were not. We did not care about exceptions. The result? In any error incident it took ages to figure out what the problem is and more importantly how to fix it.

3 1
0 1.7K

Work Queue Manager (WQM) is a feature of InterSystems IRIS that enables you to improve performance by distributing work to multiple concurrent processes programmatically. The idea is that you split the work into chunks, and WQM distributes the chunks across worker processes and can provide the info that the work is done.

However, recently, I got an interesting question: there's a large logical transaction composed of ~1,000,000 individual objects and SQL inserts and updates. Some updates are CPU-intensive, so the original idea was to use WQM to split an update into chunks to speed things up.

But, here's a catch: if one of the individual 1,000,000 changes fails (there's a variety of application-level checks so that it can fail, and that's not even that abnormal a behavior), the entire transaction must be rolled back. That creates a problem: each chunk must report success before committing their individual transactions, and someone must get all these reports and decide if we are committing or not.

Unfortunately, it looks like WQM does not have a bidirectional communication between workers and manager, so I suggested an approach using events:

  1. Start jobs.
  2. Wait for all jobs to report success using $System.Event.WaitMsg().
  3. Send Commit or Rollback using the $System.Event.Signal().
2 9
1 157

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

1 0
1 168

Hi all,

I have a rule to throw a message when there is an error. I want to prevent send the email if the origin of the error is the API to send the email

This is my rule

Now, If there is any error in any process, it works, but if there is an error in MyProduct.BO.SendEmail it is trying to send the error again, and it is a infinite loop.

Is there any way to check what is the origin and don't process if the origin is MyProduct.BO.SendEmail?

1 2
0 270
Discussion
· Sep 28, 2020
%Status usage in ObjectScript

Hi developers!

Want to discuss with you the case of %Status.

If you familiar with ObjectScript you know what is it. I'd love to hear the history of the case why it had appeared in ObjectScript but it turned out that almost every system/library classmethods return %Status and there is a whole set of tools to deal with it.

What is does it gives you the responsibility to check the value or %Status of every system method you call.

E.g. if you save the data of the persistent class, you should never call like this:

do obj.%Save()

you need to call:

set sc=obj.%Save()

if $$$ISERR(sc) do // something or quit.

1 19
0 938

Hi All,

When resending HL7 messages out, the receiving system rejects the message indicating the "Message Control ID already exists" (see error below). Iris retries resending the same message until the receiving system crashes and the BO disconnects in Iris. I would like to suspend the message when Iris receives that error and move on to the next message. Is this possible? Can it be handled by the BO Reply Code Actions settings? What reply code actions should I use?

0 4
0 143

Hello Community,.

I've updated the IRIS community form 2023.2 to 2023.3 and I didn't see the User defined(Sample) error messages in ^IRIS.Msg global even I verified in both pointer and data level. I re run the set x=##class(%MessageDictionary).Import("error.xml") After import I could see the pointers and data in ^IRIS.Msg

Is the User defined error will reset from the server after IRIS upgrade?

0 1
0 78

I have been trying to do a backup from tape using the D ^DBREST command. I am not able to connect to the tape drive, that recently got replaced. It is configured and I can see it with IBM's ITDT. I did a test and it came back with the error below:

Are there any suggestions on how to fix this or what commands to use to get this opened and connected? I do appreciate it.

0 0
0 77
Question
· May 2, 2023
JWS/JWT Header X5C

Hello All,

I'm trying to sign some custom JWT with x.509 certs but running into a problem with the signed JWT containing some information I need in the JOSE header.

Is there a way to get the "X5C:[]" header included in the signed JTW? IS this as easy as setting something like the following

Set JOSE("x5c") = "public key"

Thanks

John

0 1
0 162

I wrote a function awhile back to take Encoded Base 64 and write the PDF out to a file that could be sent to a faxing system to fax out. We are trying to test this code out in IRIS and I am seeing an error that I have not seen before... ERROR #5034: Invalid status code structure

Here is the code...

ClassMethod DecodeBase64HL7ToFile(base64 As %Stream.GlobalBinary, Ancillary As %String, FileName As %String) As %String

{

set ArchDir = "/ensemble/data/transfer/AncillaryPDF/"

0 7
0 271

Hi Community,

I have created a HL7 production in my working environment, Ens.Alert ,EMailAlert, PagerAlert, and BadMessageHandler are created.

Can anyone explain how Ens.Alert and BadMessageHandler will work when an HL7 message in Passed in Business service and how these 2 are related when any error occurs in the Production envinorment?

0 1
0 181