Tom Lord's Hackery

Error Reporting for 1.3.1

If the librification experiment continues to go well, error reporting in 1.3.1 will begin to improve.

Specifically, the librified parts of libarch use an error reporting mechanism that supports printing a "traceback" of an error.

A test command illustrates this using a fictional command that signals an error condition from deep in the call stack when provided with an even number of arguments.

Note that in this illustration, a total of six frames of the stack walkback are printed --- the shallowest three on the call stack and the deepest three. Frames are printed from shallowest to deepest and so the user sees first the error as reported by the highest level entry point and then, finally, the error as reported by the low-level function where it occured.

The number of stack frames printed in the walkback is parameterized The current setting of six is probably two verbose to use as a default; printing two (the shallowest and deepest) is probably better.

Still, by way of illustration of the new libarch capability:


    % tla try-error

    * ERROR RAISED BY `tla'
    
      In: arch_cli_hello_world
          "/usr/home/lord/wd/dists/src/tla/libarch-cli/try-error.c":69
      Error: EOPNOTSUPP
             "non-specific error"
      Category: arch
                "errors from GNU Arch"
    
        Unable to complete operation.  (This error code is primarily
        for testing purposes;  most commands should never signal this
        error.  The `try-error' command (a testing command) is an
        exception.
        
      ----- (details follow)
    
        this is a message
        printed by arch_cli_try_error
        
    
    ---from---
      In: arch_try_error
          "/usr/home/lord/wd/dists/src/tla/libarch-cli/try-error.c":134
      Error: EOPNOTSUPP
             "non-specific error"
      Category: arch
                "errors from GNU Arch"
    
        Unable to complete operation.  (This error code is primarily
        for testing purposes;  most commands should never signal this
        error.  The `try-error' command (a testing command) is an
        exception.
        
      ----- (details follow)
    
        this is a message
        printed by try_error
        
    
    ---from---
      In: arch_try_error
          "/usr/home/lord/wd/dists/src/tla/libarch-cli/try-error.c":134
      Error: EOPNOTSUPP
             "non-specific error"
      Category: arch
                "errors from GNU Arch"
    
        Unable to complete operation.  (This error code is primarily
        for testing purposes;  most commands should never signal this
        error.  The `try-error' command (a testing command) is an
        exception.
        
      ----- (details follow)
    
        this is a message
        printed by try_error
        
    
    [...]
    
    ---from---
      In: arch_try_error
          "/usr/home/lord/wd/dists/src/tla/libarch-cli/try-error.c":134
      Error: EOPNOTSUPP
             "non-specific error"
      Category: arch
                "errors from GNU Arch"
    
        Unable to complete operation.  (This error code is primarily
        for testing purposes;  most commands should never signal this
        error.  The `try-error' command (a testing command) is an
        exception.
        
      ----- (details follow)
    
        this is a message
        printed by try_error
        
    
    ---from---
      In: arch_try_error
          "/usr/home/lord/wd/dists/src/tla/libarch-cli/try-error.c":134
      Error: EOPNOTSUPP
             "non-specific error"
      Category: arch
                "errors from GNU Arch"
    
        Unable to complete operation.  (This error code is primarily
        for testing purposes;  most commands should never signal this
        error.  The `try-error' command (a testing command) is an
        exception.
        
      ----- (details follow)
    
        this is a message
        printed by try_error
        
    
    ---from---
      In: arch_try_error
          "/usr/home/lord/wd/dists/src/tla/libarch-cli/try-error.c":134
      Error: EOPNOTSUPP
             "non-specific error"
      Category: arch
                "errors from GNU Arch"
    
        Unable to complete operation.  (This error code is primarily
        for testing purposes;  most commands should never signal this
        error.  The `try-error' command (a testing command) is an
        exception.
        
      ----- (details follow)
    
        
        

Copyright

Copyright (C) 2004 Tom Lord

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

See the file COPYING for further information about the copyright and warranty status of this work.