On Thu, Aug 14, 2008 at 03:12:20PM +0800, Max Zhen wrote:

> So, in this dlpi module for Python, I followed the requirement by
> calling PyErr_SetString(PyExc_OSError, err_code_from_libdlpi_interface)
> to raise the exception whenever dlpi interface returns an error.

Wouldn't a specialized exception be more appropriate?  That would allow
people to be more specific in their error handling, and not have to wrap
calls to the dlpi methods as tightly as a generic exception would force
them to.  You could even inherit DLPIError (or whatever) from OSError, if
you like.

We (the IPS team) have been finding that re-using the existing exception
hierarchy has been very limiting, and are switching over to specialized
exceptions.

> >>       |
> >>       |  get_bcastaddr(...)
> >>       |      get_bcastaddr() -> string
> >>       |
> >>       |      Returns the broadcast address of the link.
> >>       |      See dlpi_info(3DLPI).
> >>     
> >
> > What is the link has no broadcast address?
> >   
> If dlpi_info() fails (I get broadcast address by calling dlpi_info()),
> an exception will be raised accordingly. If dlpi_info() returns no
> error, but there is no broadcast address, a string Python object, whose
> length is zero, will be returned.

Why not None?

Danek

Reply via email to