Written by

Question sansa stark · Sep 7, 2016

CSP ERRO for upgrade cache 16.1

<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

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