[sane-devel] [SANE2 proposal] Error handling

Major A andras at users.sourceforge.net
Fri Nov 28 21:39:06 GMT 2003


> Here's a proposal for SANE2 regarding error handling. As of now, error
> handling is somewhat imprecise and often not meaningful, and we're
> spending everyone's time debugging problems that could be solved
> quickly if only the user was given the appropriate status/error
> message.

Good idea... but:

> typedef struct {
>   int code;
>   char *msg;
> } SANE_Status;

OK, but that char* needs to be allocated and freed, which is always a
complication.

Also, the entire thing must be network-transparent -- any such
dramatic change to the standard would require a change in the network
protocol as well, and a char* just complicates things.

> Slightly redefine SANE_Status, as a 32bit integer where the 2 MSB are
> a backend-specific error code and the 2 LSB are a standard SANE status
> code.
> 
> The 2 LSB will always correspond to a SANE status.

Packing information into integers like this is ugly, I'm sure there's
a better way of doing things.

Here's another proposal: introduce a new standard option called
something like "last-status". This is a read-only string option, not
displayed among the normal options, that can be read out at any time,
and the returned string is simply the verbose form of the status of
the last function call to the backend. If that option is not defined,
the backend simply reverts to the SANE_Status way of reporting errors.

This doesn't require SANE2, BTW, it could be added any moment, even to
SANE1, and would be completely network-transparent.

  Andras

===========================================================================
Major Andras
    e-mail: andras at users.sourceforge.net
    www:    http://andras.webhop.org/
===========================================================================




More information about the sane-devel mailing list