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.8K

If you have system tables implementing the "VERSIONPROPERTY" functionality, you may encounter error 5800. This article explains how this error occurs and provides solutions to resolve the issue.

When version checking is implemented, the property specified by VERSIONPROPERTY is automatically incremented each time an instance of the class is updated (either by objects or SQL).

For example:

6 0
0 61
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
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 297

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 172

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 273

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 182
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 953

I have some code in a mac routine that use indentation and the "." character :

 IF condition1 DO
     .WRITE YCR,...
     .WRITE YCR,...
     .WRITE YCR,...

I would like to add a try / catch block between the write statements.
I can't refactor the whole code and use indentation with curly braces instead (there is too much code, not written by me)

I have tried the following but it does not work (it compiles, but code stop running right before the try keyword)

0 2
0 254

The intersystems documentation gives the same description for both <MAXSTRING> and <NETWORK DATA UPDATE FAILED - MAXSTRING>. I suspect that the description for <MAXSTRING> is correct and the description for <NETWORK DATA UPDATE FAILED - MAXSTRING> was an accident. I would like to know what situation triggers the <NETWORK DATA UPDATE FAILED - MAXSTRING> error.

0 2
0 397

Hey everyone as you may know I am a beginner and I am kindly asking for some assistance in a problem I have been solving. The problem is that I am calling a user defined function within a procedure called occupiedseatsAdj and the compiler comes up with this error.

0 2
0 167

New to Health Connect so please forgive me if this is a stupid question! Is there a specific error code returned when a user initiates an abort from the jobs tab of the business host? I want to be able to treat the Abort as Completed due to our complex business process. Currently, hitting abort just retries the message to the same business operation. Want I want to do is provide the error code used by the Abort (if there is one) and treat it as OK

Thanks in advance.

0 4
0 334

How can I prevent large number truncation when using the DynamicObject and DynamicArray classes to create JSON in objectscript and then parsing the result in javascript. Are there any global settings that configure the output when using these classes?

I am looking at converting to the new DynamicObject and DynamicArray classes to build JSON. Our current (homegrown) JSON library forces string representation of numbers too long because of errors we were seeing with long numbers being truncated on the client, I am hoping to accomplish the same with the new classes.

0 2
0 1.2K

Hello,

I'm experiencing a recurrent problem that I haven't found the way to solve, so I'm coming here with the hope somebody can give me a new approach.

To make it short: we are creating categories on-demand to be able to place the maximum numbers of workers in memory, avoiding the limits established by system categories. But from time to time, one of this creation fails and system is no able to start the queue. The error we are getting is:

0 1
0 213

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 279