Eduard Lebedyuk · Jun 2, 2017 go to post

Here's how you can define your own errors.

Create messages.xml with your error messages:

<?xml version="1.0" encoding="UTF-8"?>
<MsgFile Language="en">
    <MsgDomain Domain="asd">
        <Message Id="-1" Name="ErrorName1">Your error 1</Message>
        <Message Id="-2" Name="ErrorName2">Some other error 2 %1 %2</Message>
    </MsgDomain>
</MsgFile>

Import it into Cache:

do ##class(%MessageDictionary).Import("messages.xml")

It will result in two globals being populated:

  • ^CacheMsg
USER>zw ^CacheMsg 
^CacheMsg("asd","ru",-2)="Some other error 2" 
^CacheMsg("asd","ru",-1)="Your error 1"
  •   ^CacheMsgNames
USER>zw ^CacheMsgNames 
^CacheMsgNames("asd",-2)="ErrorName2" 
^CacheMsgNames("asd",-1)="ErrorName1"

Next we generate CustomErrors include file (docs):

USER>Do ##class(%MessageDictionary).GenerateInclude("CustomErrors",,"asd",1) 
Generating CustomErrors.INC ...

Here's what CustomErrors.inc looks like:

#define asdErrorName2 "<asd>-2"
#define asdErrorName1 "<asd>-1"

Now we can use new custom errors:

Include CustomErrors

Class demo.test [ Abstract ]
{

ClassMethod test(A As %Integer) As %Status
{
  if A=1 Quit $$$ERROR($$$asdErrorName1)
  if A=2 Quit $$$ERROR($$$asdErrorName2,"f","6")
  Quit $$$OK
}

}

Results in:

USER>d $system.OBJ.DisplayError(##class(demo.test).test(1))

ERROR <asd>-1: Your error 1

USER>d $system.OBJ.DisplayError(##class(demo.test).test(2))

ERROR <asd>-2: Some other error 2 f 6

Text is not mine, translated from here.

Eduard Lebedyuk · Jun 1, 2017 go to post

Here's a very simple Ensemble REST service. That said, I recommend usual %CSP.REST broker  with calls to Ensemble via Ens.Director:CreateBusinessService. Check Demo.ZenService.Zen.WeatherReportForm class, GetWeatherReport method in ENSDEMO namespace for an example.

Eduard Lebedyuk · Jun 1, 2017 go to post

Check %ZEN.Auxiliary.altJSONProvider class, %UnpackObjectToCOSObjectmethod, it converts dynamic object to the specified class.

Set dynamicObject = {}.%FromJSON(%request.Content)
Set object = ##class(%ZEN.Auxiliary.altJSONProvider).%UnpackObjectToCOSObject(dynamicObject, "class")
Eduard Lebedyuk · May 31, 2017 go to post

Compare "Enabled ciphersuites" property in your SSL/TLS configuration.

But you'll probably need a longer key.

Eduard Lebedyuk · May 30, 2017 go to post

They are stored as objects of Ens.Config.DefaultSettings class.

You can:

  • Export the ^Ens.Config.DefaultSettingsD global
  • Export Ens_Config.DefaultSettings table contents to CSV, etc.
  • Export settings as objects to XML
Eduard Lebedyuk · May 29, 2017 go to post

If you store data in globals, you can run parallel jobs on your data.

On a single job however, locals are faster because there's no journaling and disk writes.

Eduard Lebedyuk · May 26, 2017 go to post

%OnAddToSaveSet() can get called many times during modification or saving of our target object and all objects related to it. Therefore it's better to move code we need to execute once to triggers or initialexpression or sqlcomputed.

Eduard Lebedyuk · May 26, 2017 go to post

Please note that It's not recommended to use %OnAddToSaveSet(), especially performing heavy operations there.

Eduard Lebedyuk · May 24, 2017 go to post

Like this:

set p = ##class(%SYS.ProcessQuery).%OpenId($job)
set p.UserInfo = "My Text"
kill p
Eduard Lebedyuk · May 19, 2017 go to post

In your %XML.Reader set IgnoreSAXWarnings to 1.

In your XML enabled classes set params:

Parameter XMLIGNOREINVALIDTAG As BOOLEAN = 1;
Parameter XMLIGNOREINVALIDATTRIBUTE As BOOLEAN = 1;

This would allow for errors to be skipped, but they wouldn't be reported either.

I'm not sure if the behavior you want is possible without some modifications.

Eduard Lebedyuk · May 18, 2017 go to post

Here's a few thoughts:

  1. Get list of pivots
  2. For each
    • Get MDX
    • Try to execute MDX
    • If it fails, record the error
  3. Aggregate/display errors

Should be doable. DeepSee API has all the required functions.

Eduard Lebedyuk · May 16, 2017 go to post

Check UserAction method of %Studio.Extension.Base class. You can call CSP pages from there.

Eduard Lebedyuk · May 14, 2017 go to post

Write statement does what it's name implies - outputs characters into a current device. It's a way to go if you're working from a terminal, but ZEN does it's own device management, so writing into a current device interferes with ZEN also writing into current device, which causes an error.

 

To make it work check if there's no data (SQLCODE=100) and set OutVal to empty (or error message) and work with that on a client.

Eduard Lebedyuk · May 13, 2017 go to post

HttpResponse property contains response. Here's a sample:

Set req = ##class(%Net.HttpRequest).%New()
// build the request
Do req.Post("url")
Set str = req.HttpResponse.Data.Read()
Write str