Written by

Question sansa stark · Sep 7, 2016

CSP ERRO for upgrade cache 16.1

Hi All,

      While upgrade cache 5.02 to cache 16.

     $$$CacheError and $$$CacheError not support in cache 16. 
     We need solution for this?

<csp:CLASS super=%CSP.Error>

<script language=Cache method=OnPreHTTP arguments="" returntype=%Boolean> Quit 1 </script> <script language=Cache method=HyperEventError arguments="" returntype=""> New ErrorInfo,ErrorNumber,message Do ..DecomposeError(%request.Get("Error:ErrorCode"),.ErrorInfo) Set message="Show System Error Message\n\n" For i=1:1:ErrorInfo { Set message=message_$ZCVT(ErrorInfo(i,"Desc"),"O","JS")_"\n" Set message=message_$ZCVT(" Error: "_ErrorInfo(i,"Error"),"O","JS")_"\n" If ErrorInfo(i,"ErrorNo")'=$$$CacheError,ErrorInfo(i,"ErrorNo")'=$$$FailedToCreateClass Set message=message_$ZCVT(" ErrorNo: "_ErrorInfo(i,"ErrorNo"),"O","JS")_"\n" Set message=message_$ZCVT(" CSP Page: "_ErrorInfo(i,"URL"),"O","JS")_"\n" Set message=message_$ZCVT(" Namespace: "_ErrorInfo(i,"Namespace"),"O","JS")_"\n" Set message=message_$ZCVT(" Class: "_ErrorInfo(i,"Class"),"O","JS")_"\n" If $G(ErrorInfo(i,"Routine"))'="" { Set message=message_$ZCVT(" Routine: "_ErrorInfo(i,"Routine"),"O","JS")_"\n" Set message=message_$ZCVT(" Location: "_ErrorInfo(i,"Location"),"O","JS")_"\n" If $G(ErrorInfo(i,"Line"))'="" Set message=message_$ZCVT(" Line: "_ErrorInfo(i,"Line"),"O","JS")_"\n" } Set message=message_"\n\n\nPlease contact the site administrator.\n" } Write "alert('",message,"');",! ; As we are outputting JavaScript we can also do things like redirect the browser depending on the error. ; For example if the session timed out, or was ended directly then when the user tries to go to a page ; that contains encrypted data in the parameter they will get one of these two errors. If so we redirect ; them to a login page.. Set ErrorNumber=%request.Get("Error:ErrorNumber") If ErrorNumber=$$$CSPSessionTimeout!(ErrorNumber=$$$InvalidDecrypt) { Write "CSPPage.window.location='/csp/user/ShowLogin.csp'",! } </script> &html<

Show System Error Message

> New ErrorInfo Do ..DecomposeError(%request.Get("Error:ErrorCode"),.ErrorInfo) Do ..DisplayError(.ErrorInfo) ; &html<


> ; Call the inspector to display the objects assocaited with this request. ; Note this is done inside the tags. ; Do ##class(%CSP.Utils).DisplayAllObjects() &html<

Please contact the site administrator.

> Quit

In this csp page while compare the following error occurred.

ling class csp.error Compiling routine csp.error.1 ERROR: csp.error.cls(HyperEventError+7) : MPP5610 : Referenced macro not defined: 'CacheError' TEXT: If ErrorInfo(i,"ErrorNo")'=$$$CacheError,ErrorInfo(i,"ErrorNo")'=$$$FailedToCreateClass Set message=message_$ZCVT(" ErrorNo: "ErrorInfo(i,"ErrorNo"),"O","JS")"\n" ERROR: csp.error.cls(HyperEventError+25) : MPP5610 : Referenced macro not defined: 'CSPSessionTimeout' TEXT: If ErrorNumber=$$$CSPSessionTimeout!(ErrorNumber=$$$InvalidDecrypt) { ERROR: csp.error.cls(HyperEventError+7) #1002: Invalid character in tag : 'ErrorInfo(i,"ErrorNo")'=$$$CacheError,ErrorInfo(i,"ErrorNo")'=$$$FailedToCreateClass' : Offset:33 [zHyperEventError+7^csp.error.1] TEXT: If ErrorInfo(i,"ErrorNo")'=$$$CacheError,ErrorInfo(i,"ErrorNo")'=$$$FailedToCreateClass Set message=message_$ZCVT(" ErrorNo: "ErrorInfo(i,"ErrorNo"),"O","JS")"\n" ERROR: csp.error.cls(HyperEventError+25) #1002: Invalid character in tag : 'ErrorNumber=$$$CSPSessionTimeout!(ErrorNumber=$$$InvalidDecrypt)' : Offset:20 [zHyperEventError+24^csp.error.1] TEXT: If ErrorNumber=$$$CSPSessionTimeout!(ErrorNumber=$$$InvalidDecrypt) { ERROR: csp.error.cls(HyperEventError+27) #1026: Invalid command : '}' : Offset:2 [zHyperEventError+26^csp.error.1] TEXT: } ERROR #5908: Failed to create class 'csp.error': ERROR #5475: Error compiling routine: csp.error. Errors: csp.error.cls(HyperEventError+7) : MPP5610 : Referenced macro not defined: 'CacheError' TEXT: If ErrorInfo(i,"ErrorNo")'=$$$CacheError,ErrorInfo(i,"ErrorNo")'=$$$FailedToCreateClass Set message=message_$ZCVT(" ErrorNo: "ErrorInfo(i,"ErrorNo"),"O","JS")"\n" Detected 6 errors during compilation in 0.100s.

Thanks, sanasa.

Comments

Mark Hanson · Sep 7, 2016

I think we may need some more context of what the code looks like and exactly what error message you are getting. We do support $$$CacheError in 2016.1, for example:

Set status=$$$ERROR($$$CacheError,$zerror)

If you are trying to lookup the macro value then use $$$ERRORCODE($$$CacheError), then you can write logic like:

If errorcode=$$$ERRORCODE($$$CacheError) Write "It was a Cache error",!
0