Skip to content

Commit

Permalink
fix error in preload script
Browse files Browse the repository at this point in the history
  • Loading branch information
isc-shuliu committed Jun 3, 2024
1 parent b7d7a36 commit 0087e76
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions preload/cls/_ZAPM/compat/Compat.cls
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,35 @@ Class %ZAPM.compat.Compat
/// Will be invoked after Reload and before Compile
ClassMethod CheckCompatibility()
{
Write !, $c(9)_"Checking namespace compatibility..."
If $Namespace '= "%SYS" {
Throw ##class(%Exception.General).%New("This application must be installed in the ""%SYS"" namespace ")
Throw ..GetError("This application must be installed in the ""%SYS"" namespace")
}
Write " OK!"
// Some classes have been renamed in IPM (v0.9+).
// The following code will change the class definition to the old class name for backward compatibility
Write !, $c(9)_"Checking package manager version compatibility..."
Set oldClass = "%ZPM.PackageManager.Developer.Lifecycle.Module"
Set newClass = "%IPM.Lifecycle.Module"
if ##class(%Dictionary.ClassDefinition).%ExistsId(newClass) {
If ##class(%Dictionary.ClassDefinition).%ExistsId(newClass) {
Return
} ElseIf '##class(%Dictionary.ClassDefinition).%ExistsId(oldClass) {
Throw ##class(%Exception.General).%New("Neither "_oldClass_" nor "_newClass_" exists. Please check your installation of zpm/ipm")
Throw ..GetError("Neither "_oldClass_" nor "_newClass_" exists. Please check your installation of zpm/ipm")
}
set classname = "%zapm.ext.Lifecycle"
set cls = ##class(%Dictionary.ClassDefinition).%OpenId(classname)
if '$IsObject(cls) {
Throw ##class(%Exception.General).%New("Class "_ classname _" does not exist. Please check your src folder")
Set classname = "%ZAPM.ext.Lifecycle"
Set cls = ##class(%Dictionary.ClassDefinition).%OpenId(classname)
If '$IsObject(cls) {
Throw ..GetError("Class "_ classname _" does not exist. Please check your src folder")
}
set cls.super = oldClass
Set cls.Super = oldClass
$$$ThrowOnError(cls.%Save())
Write " OK!"
}

ClassMethod GetError(msg As %String) As %Exception.General [ Internal, Private ]
{
Write !, "ERROR: ", msg, !
Return ##class(%Exception.General).%New(msg)
}

}

0 comments on commit 0087e76

Please sign in to comment.