Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You do have to do it the hard way, but it's not really all <strong><em>that</em></strong> hard... Seriously, once you've written the template once, it's a quick copy/paste/modify to match the function name in the Err.Raise statement to the actual function name.</p> <pre><code>Private Function DoSomething(ByVal Arg as String) On Error GoTo Handler Dim ThisVar as String Dim ThatVar as Long ' Code here to implement DoSomething... Exit Function Handler: Err.Raise Err.Number, , "MiscFunctions.DoSomething: " &amp; Err.Description End Function </code></pre> <p>When you have nested calls, this unwinds as each routine hits its Handler and adds its name to the error description. At the top level function, you get a "call stack" showing the list of routines that were called, and the error number and description of the error that actually occurred. It's not perfect, in that you don't get line numbers, but I've found that you don't usually need them to find your way to the problem. (And if you really want line numbers, you can put them in the function and reference them in the Err.Raise statement using the Erl variable. Without line numbers, that just returns 0.)</p> <p>Also, note that within the function itself, you can raise your own errors with the values of interesting variables in the message like so:</p> <pre><code>Err.Raise PCLOADLETTER_ERRNUM, , "PC Load Letter error on Printer """ &amp; PrinterName &amp; """" </code></pre> <p>(The syntax highlighting looks wonky in the preview... I wonder how will it look when posted?)</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload