%Installer Manifest: How to ignore several kinds of compilation errors?

Primary tabs

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.

  • + 3
  • 0
  • 235
  • 7
  • 2

Answers

This just looks like a bug - the generated code is:

Do tInstaller.Import(tNSName,tInstaller.Evaluate("${AddonDir}/AddClasses.xml"),"ck","5202","5373","0")

While you would expect:

Do tInstaller.Import(tNSName,tInstaller.Evaluate("${AddonDir}/AddClasses.xml"),"ck","5202,5373","0")

Here's a possible workaround (untested, but the generated code looks better):

<Var Name="AddClassesErrors" Value="5202,5373" />
<If Condition='#{##class(%File).Exists("${AddonDir}/AddClasses.xml")}'>
  <Import File="${AddonDir}/AddClasses.xml" IgnoreErrors="${AddClassesErrors}" Flags="ck" />
</If>

EDIT: actual workaround (see discussion below) is to use #{<COS_expression>} (see documentation).

<Var Name="AddClassesErrors" Value="#{&quot;5202,5373&quot;}" />
<If Condition='#{##class(%File).Exists("${AddonDir}/AddClasses.xml")}'>
  <Import File="${AddonDir}/AddClasses.xml" IgnoreErrors="${AddClassesErrors}" Flags="ck" />
</If>

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. 

<Var Name="AddClassesErrors" Value="5202,5373" />

is transformed to

Do tInstaller.SetVariable("AddClassesErrors","5202","5373")

That isn't valid XML - I think it'd need to be:

<Var Name="AddClassesErrors" Value="&quot;,5202,5373,&quot;" />

The &quot; makes it smarter about it being one string, and the extra commas should make it work with the test condition in %Installer.Install:Import:

((","_pIgnoreErrors_",")[(","_$P($system.Status.GetErrorCodes(tSC),",")_","))

This is messy! sad

EDIT: Better option:

<Var Name="AddClassesErrors" Value="#{&quot;5202,5373&quot;}" />

Timothy,

Both options succeded. Thank you so much! 

Just FYI, your 1st option

<Var Name="AddClassesErrors" Value="&quot;,5202,5373,&quot;" />

generated a code:

Do tInstaller.SetVariable("AddClassesErrors",""",5202,5373,""")

and the 2nd one

<Var Name="AddClassesErrors" Value="#{&quot;5202,5373&quot;}" />

generated:

Do tInstaller.SetVariable("AddClassesErrors",tInstaller.Evaluate("#{""5202,5373""}"))

 

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).

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"