Error trapping for module open operation

Hello everybody,

is anyone aware of a solution for the following problem:

A DXL program opens a module; that module has some errorneous code in it and causes some error during opening. Assumed that the DXL program is a batch, this is a killer, because the error dialog waits for an interaction > the program hangs.

Any creative ideas appreciated, be it inside (where's probably none) or outside DXL...

Regards,
Gerhard
GerhardS - Tue Jun 07 12:12:33 EDT 2011

Re: Error trapping for module open operation
SystemAdmin - Tue Jun 07 12:27:44 EDT 2011

Hi Gerhard,

either open the module using the Standard View, then no error caused by DXL attributes should pop up while the module is opened (i.e. Module edit(string name [,bool disp[, bool silent, bool loadStandardView]])

or use a construct like

noError()
edit (...)
if lastError() then {printout_my_error(...) ; continue}
Hope this helps,
Mike

Re: Error trapping for module open operation
GerhardS - Tue Jun 07 12:41:52 EDT 2011

SystemAdmin - Tue Jun 07 12:27:44 EDT 2011
Hi Gerhard,

either open the module using the Standard View, then no error caused by DXL attributes should pop up while the module is opened (i.e. Module edit(string name [,bool disp[, bool silent, bool loadStandardView]])

or use a construct like

noError()
edit (...)
if lastError() then {printout_my_error(...) ; continue}
Hope this helps,
Mike

Thanks, Mike, for the hint.

Actually, the reasons for getting an error are many, so the question is, if the noError constuct covers all of them. I already tried that, but it seemed to me that some situations are not trapped hereby.

However, in addition with the standard view approach, it should provide a wide coverage of situations.

Regards,
Gerhard

Re: Error trapping for module open operation
llandale - Tue Jun 07 14:17:14 EDT 2011

Here's are some observations.

When you open a module, either visibly or invisibly, all Attr DXL that applies at the Module level is Evaluated, and any DXL errors therein are rudely printed along with that annoying "DXL Contains X errors" dialog, the bane of BatchMode. Also, visibly or invisibly, the default view is indeed loaded and any layout code is evaluated and any errors likewise are rudely reported. When Visible, displayed AttrDXL is also evaluated (and run).

One take-away from that is to avoid defining Attr DXL for the module, which rarely makes sense anyway. You should also routinely load the Standard view when opening modules.

You can trap the AttrDXL and Layout errors above by surrounding the "read" with noError() and lastError().

A big source of DXL errors are when sensible folks have AutoDeclare turned off but are running AttrDXL or Layouts written by silly folks who develop their DXL with AutoDeclare on.

Module Open and Close triggers are another matter and are NOT trapped via noError()/lastError(). DB admins can turn running of Triggers off resolving the issue, but Standard users cannot (OK, technically they can turn off triggers but that option is ignored for Standard users and Triggers will run).

So, here's a clumsy looking approach.

bool TrigsEnabled = getTriggerState_()              // Remember current state
setTriggerState_(false)                             // turn off Triggers
bool      AutoWasOn = (XFLAGS_ & AutoDeclare_ != 0)   // Remember whether it was On/Off
XFLAGS_ &=~AutoDeclare_                             // turn off AutoDeclare
 
noError()
mod = read(NameMod, false, true)    // Invisibly, load standard view
   // mod = edit(NameMod, false, true, true // Invisible, WhenLockedDon'tPromptRead, load standard view
lastError()
    // string ErrMess = lastError()
    // Printing ErrMess is not useful as you only get the LAST error, "all done with 2 errors".
 
                  // now re-instate the previous AutoDeclare and Trigger On/Off state:
if    (AutoWasOn) //
then XFLAGS_ |= AutoDeclare_    // Turn it ON
else XFLAGS_ &=~AutoDeclare_        // Turn it OFF
setTriggerState_(TrigsEnabled)  // Reinstate trigger state.

 


When I get some time (or some help here) I'll figure out how to suppress DXL errors in Triggers, without actually disabling them. I'm wondering if using "eval_" to do the open will work.

 

 

 

  • Louie

 

 

Re: Error trapping for module open operation
GerhardS - Tue Jun 07 14:44:47 EDT 2011

llandale - Tue Jun 07 14:17:14 EDT 2011

Here's are some observations.

When you open a module, either visibly or invisibly, all Attr DXL that applies at the Module level is Evaluated, and any DXL errors therein are rudely printed along with that annoying "DXL Contains X errors" dialog, the bane of BatchMode. Also, visibly or invisibly, the default view is indeed loaded and any layout code is evaluated and any errors likewise are rudely reported. When Visible, displayed AttrDXL is also evaluated (and run).

One take-away from that is to avoid defining Attr DXL for the module, which rarely makes sense anyway. You should also routinely load the Standard view when opening modules.

You can trap the AttrDXL and Layout errors above by surrounding the "read" with noError() and lastError().

A big source of DXL errors are when sensible folks have AutoDeclare turned off but are running AttrDXL or Layouts written by silly folks who develop their DXL with AutoDeclare on.

Module Open and Close triggers are another matter and are NOT trapped via noError()/lastError(). DB admins can turn running of Triggers off resolving the issue, but Standard users cannot (OK, technically they can turn off triggers but that option is ignored for Standard users and Triggers will run).

So, here's a clumsy looking approach.

bool TrigsEnabled = getTriggerState_()              // Remember current state
setTriggerState_(false)                             // turn off Triggers
bool      AutoWasOn = (XFLAGS_ & AutoDeclare_ != 0)   // Remember whether it was On/Off
XFLAGS_ &=~AutoDeclare_                             // turn off AutoDeclare
 
noError()
mod = read(NameMod, false, true)    // Invisibly, load standard view
   // mod = edit(NameMod, false, true, true // Invisible, WhenLockedDon'tPromptRead, load standard view
lastError()
    // string ErrMess = lastError()
    // Printing ErrMess is not useful as you only get the LAST error, "all done with 2 errors".
 
                  // now re-instate the previous AutoDeclare and Trigger On/Off state:
if    (AutoWasOn) //
then XFLAGS_ |= AutoDeclare_    // Turn it ON
else XFLAGS_ &=~AutoDeclare_        // Turn it OFF
setTriggerState_(TrigsEnabled)  // Reinstate trigger state.

 


When I get some time (or some help here) I'll figure out how to suppress DXL errors in Triggers, without actually disabling them. I'm wondering if using "eval_" to do the open will work.

 

 

 

  • Louie

 

 

Well, I have made a strange observation regarding the noError / lastError handling. I created a wrapper function for the read module function:
 

Module    op_readModule(string pStrName, bool pBoolDisplay, bool pBoolLoadStandardView)
{
(declarations and preparation stuff)
...
        // switch off errors                    
        noError()
        
        // create the dxl code
        strDxlCode = "noError(); read(\"" pStrName "\", " pBoolDisplay ", " pBoolLoadStandardView "); return_(lastError())"
        debug_print(strFunction, "dxl code: " strDxlCode "")
 
        strError = eval_(strDxlCode)
        debug_print(strFunction, "eval error: " strError "")
 
        // open the module
        if (strError == "")
        {
                noError()
                modCurrent = read(pStrName, pBoolDisplay, pBoolLoadStandardView)
 
                // get the error
                strError = lastError()  
                debug_print(strFunction, "error status: " strError "")
        }
        else
(...)
(handle some more situations, e.g., close a possibly opened module)
}

 


I added the eval() stuff, because the noError/lastError bracket alone did continue showing me the error dialog box.

In fact, the first strError shows correctly the error message from the eval-read, but anyway the corresponding error dialog box still shows up. However, as I understood from the previous discussion, this should actually NOT be the case. Or did I miss some detail?

Regards,
Gerhard

 

Re: Error trapping for module open operation
GerhardS - Tue Jun 07 14:46:01 EDT 2011

GerhardS - Tue Jun 07 14:44:47 EDT 2011

Well, I have made a strange observation regarding the noError / lastError handling. I created a wrapper function for the read module function:
 

Module    op_readModule(string pStrName, bool pBoolDisplay, bool pBoolLoadStandardView)
{
(declarations and preparation stuff)
...
        // switch off errors                    
        noError()
        
        // create the dxl code
        strDxlCode = "noError(); read(\"" pStrName "\", " pBoolDisplay ", " pBoolLoadStandardView "); return_(lastError())"
        debug_print(strFunction, "dxl code: " strDxlCode "")
 
        strError = eval_(strDxlCode)
        debug_print(strFunction, "eval error: " strError "")
 
        // open the module
        if (strError == "")
        {
                noError()
                modCurrent = read(pStrName, pBoolDisplay, pBoolLoadStandardView)
 
                // get the error
                strError = lastError()  
                debug_print(strFunction, "error status: " strError "")
        }
        else
(...)
(handle some more situations, e.g., close a possibly opened module)
}

 


I added the eval() stuff, because the noError/lastError bracket alone did continue showing me the error dialog box.

In fact, the first strError shows correctly the error message from the eval-read, but anyway the corresponding error dialog box still shows up. However, as I understood from the previous discussion, this should actually NOT be the case. Or did I miss some detail?

Regards,
Gerhard

 

...I should add that the error in the module results from a DXL attribute referencing a non-existing #include file....

Re: Error trapping for module open operation
GerhardS - Sat Jul 09 02:41:30 EDT 2011

llandale - Tue Jun 07 14:17:14 EDT 2011

Here's are some observations.

When you open a module, either visibly or invisibly, all Attr DXL that applies at the Module level is Evaluated, and any DXL errors therein are rudely printed along with that annoying "DXL Contains X errors" dialog, the bane of BatchMode. Also, visibly or invisibly, the default view is indeed loaded and any layout code is evaluated and any errors likewise are rudely reported. When Visible, displayed AttrDXL is also evaluated (and run).

One take-away from that is to avoid defining Attr DXL for the module, which rarely makes sense anyway. You should also routinely load the Standard view when opening modules.

You can trap the AttrDXL and Layout errors above by surrounding the "read" with noError() and lastError().

A big source of DXL errors are when sensible folks have AutoDeclare turned off but are running AttrDXL or Layouts written by silly folks who develop their DXL with AutoDeclare on.

Module Open and Close triggers are another matter and are NOT trapped via noError()/lastError(). DB admins can turn running of Triggers off resolving the issue, but Standard users cannot (OK, technically they can turn off triggers but that option is ignored for Standard users and Triggers will run).

So, here's a clumsy looking approach.

bool TrigsEnabled = getTriggerState_()              // Remember current state
setTriggerState_(false)                             // turn off Triggers
bool      AutoWasOn = (XFLAGS_ & AutoDeclare_ != 0)   // Remember whether it was On/Off
XFLAGS_ &=~AutoDeclare_                             // turn off AutoDeclare
 
noError()
mod = read(NameMod, false, true)    // Invisibly, load standard view
   // mod = edit(NameMod, false, true, true // Invisible, WhenLockedDon'tPromptRead, load standard view
lastError()
    // string ErrMess = lastError()
    // Printing ErrMess is not useful as you only get the LAST error, "all done with 2 errors".
 
                  // now re-instate the previous AutoDeclare and Trigger On/Off state:
if    (AutoWasOn) //
then XFLAGS_ |= AutoDeclare_    // Turn it ON
else XFLAGS_ &=~AutoDeclare_        // Turn it OFF
setTriggerState_(TrigsEnabled)  // Reinstate trigger state.

 


When I get some time (or some help here) I'll figure out how to suppress DXL errors in Triggers, without actually disabling them. I'm wondering if using "eval_" to do the open will work.

 

 

 

  • Louie

 

 

Thanks a lot for your explanation, this helps me on.

Regards
Gerhard

Re: Error trapping for module open operation
llandale - Sat Jul 09 18:42:54 EDT 2011

GerhardS - Tue Jun 07 14:46:01 EDT 2011
...I should add that the error in the module results from a DXL attribute referencing a non-existing #include file....

I recall, but then forgot to follow up on this. The #include errors won't get stopped nor trapped. You may need to go the logfile route, which stops the DXL window and sends them to a file. IIRC, its a command line switch: -logfile "c:\Reports\DXL_BatchErrors.txt"

  • Louie