%Installer Manifest: How to ignore several kinds of compilation errors?
Due to a new project I'm getting involved inside %Installer stuff deeper than ever I'd be happy to. Most of it was pretty easy to get, thanks to documentation, articles and SAMPLES example, while I can't dig good solution for one problem. I'm trying to import and compile some classes, willing to ignore two types of errors: 5202 (NothingToCompile) and 5373 (PredecessorClassDoesNotExist - a normal case when SNMP sampling class is compiled for the 1st time, before it was registered).
I've tried the following:
<If Condition='#{##class(%File).Exists("${AddonDir}/AddClasses.xml")}'> <Import File="${AddonDir}/AddClasses.xml" IgnoreErrors="5202,5373" Flags="ck" /> </If>
While it was compiled w/o errors, the mainfest execution failed with error:
03/28/17-16:20:29:521 (2728) 2 Error: #5002: <PARAMETER>zImport^%Installer.Installer.1
I've found a code inside %Installer.Installer::Import():
If $$$ISERR(tSC),(pIgnoreErrors=1)||((","_pIgnoreErrors_",")[(","_$P($system.Status.GetErrorCodes(tSC),",")_",")) { Do ..Log(2,"Import","Ignoring Errors: ("_$P($system.Status.GetErrorCodes(tSC),",")_") "_$system.Status.GetErrorText(tSC)) Set tSC = $$$OK }
which reassured me that IgnoreErrors can be a comma separated list.
I understand that I can split my classes' export in two files and ignore all errors for 'buggy' one of them by setting IgnoreErrors="1", but still eager to know if more elegant solution exists.
Thank you.
What does it output when you run it with IgnoreErrors=1 in the Ignoring Errors: log lines? Sometimes it reports multiple errors there (like 5000,5202) -- so by looking at code you'll need to add those in your list: "5000,5202,5000,5373"
Hi Timothy and Sergey,
Timothy, putting the literal codes list inside a variable doesn't help much: I'm getting the same error.
Thank you anyway.
P.S. The reason of the issue is a wrong code for variable evaluation, e.g.
is transformed to
This just looks like a bug - the generated code is:
While you would expect:
Here's a possible workaround (untested, but the generated code looks better):
EDIT: actual workaround (see discussion below) is to use #{<COS_expression>} (see documentation).
Can you try IgnoreErrors="""5202,5373"""
That isn't valid XML - I think it'd need to be:
The " makes it smarter about it being one string, and the extra commas should make it work with the test condition in %Installer.Install:Import:
This is messy!
EDIT: Better option:
Timothy,
Both options succeded. Thank you so much!
Just FYI, your 1st option
generated a code:
and the 2nd one
generated:
Right - the first one happens to work in this case, but the second one should work in any case where a comma isn't accepted (and should evaluate to the correct string).
Still looks like a bug -- probably worth reporting somewhere... On the other hand it will probably break current solution once fixed.
Eduard actually reported the same error occuring in a different case a while ago. I added some notes to the bug report earlier (138510).
Timothy,
Both options succeded. Thank you so much!
Just FYI, your 1st option
generated a code:
and the 2nd one
generated:
I've got into another issue trying to write a code which should configure some global mapping to already existing namespace. Here is its skeleton:
I've started it at the same Cache instance where I wrote it with following commands:
zn "USER1" s sc=##class(%z.Mapping).RunInstallWithLog($zu(12)_"mapping.log",2) d:'sc $system.Status.DisplayError(sc)
And it works. But if I'm excluding an [unneeded] code fragment that resides between two lines:
<!-- ??? Configure the database that should exist upto this step -->
I'm getting several errors, please see below. Why this fragment is still needed nevertheless I marked my namespace with Create="no" attribute?