No announcement yet.

Avoid trapping error 0

  • Filter
  • Time
  • Show
Clear All
new posts

  • Avoid trapping error 0

    The function ShowError is a copy of part of WinErr for PB CC.
    I found by experiment that the On Error works TOO well - intermittently
    gives "Error 0 = The operation completed succesfully".
    Using "If ErrApi then BtmLneErr" does not do this.
    But neither method replaces or precedes the Window messages about
    "... illegal operation and will be shut down" which is precisely the
    object of the excercise.
    Function ShowError (ByVal x&) As String
     If ErrApi Then ShwErrErr
      FormatMessage %FORMAT_MESSAGE_FROM_SYSTEM, ByVal %NULL, x&, %NULL, errbfr, SizeOf(errbfr), ByVal %NULL
      If Len(errbfr) Then
        Function = "Error " & Format$(x&) & " = " & errbfr
        Function = "Unknown error code: " & Format$(x&)
      End If
     Exit Function
     MsgBox(showError(ErrApi)+" in WPtester, ShowError")
     End Function      '(ShowError)
    Function BottomLine (ByVal cL&) As Long
     If ErrApi Then BtmLneErr
    ' On Error Goto BtmLneErr
     While cL&<dtlCnt& And Val(Left$(IstLst$(cL&+1),4))=Val(Left$(IstLst$(cL&),4))
      Incr cL&
      Wend              'Establish the LAST line (on screen) of the
     Function=cL&       'order item per cL& (see sub SetFirstLastList
     Exit Function      'above)
     MsgBox(showError(ErrApi)+" in WPtester, BottomLine")
     End Function      '(BottomLine)

    Last edited by Gary Beene; 12 Jul 2014, 08:59 PM. Reason: Code: tags

  • #2
    I had the same problem once. Did some reading and realized not all API calls Set "Last Error" or provide a value to the GetLastError call (which I assum is the underlying function servicing the PB ERRAPI function).

    For calls which don't, you can use the SetLastError API to tell Windows what to look for. But unless you know which APIs the PBRT calls, in what order, this may get you precisely nowhere.


    Michael Mattias
    Tal Systems (retired)
    Port Washington WI USA
    [email protected]


    • #3
      Thanks, Michael. In any event my code as posted would not be very
      useful since the ErrApi has to be present upon entry, and will
      definitely have arisen in a preceding sub or function.

      One could also try

      On error goto xxxErr

      and there ---

      if ErrApi=0 then resume dword abc

      --- but to maintain the dword (abc) makes it totally
      impracticable, also labeling EVERY LINE of code!!!

      Pity; the error in text form would be extremely useful to those
      who can't make sense of the register values/stack dumps etc.
      provided with the Windows ultimati.