Mailinglist Archive: yast-devel (50 mails)

< Previous Next >
Re: [yast-devel] New libstorage: Returning NULL pointers vs. throwing exceptions
On Tue, Dec 01, 2015 at 02:09:21PM +0100, Josef Reidinger wrote:
On Tue, 1 Dec 2015 13:46:12 +0100
Arvin Schnell <aschnell@xxxxxxxx> wrote:

No, to quote Stroustrup: "exceptions are used to signal errors
that cannot be handled locally". Casting to a wrong type or
requesting a non-existing object is an error that cannot be
handled locally and thus must be signaled, e.g. by an exception.

I fully agree with stroustrup that if you have error that cannot
be handled locally raise exception. Still I do not see how having disk
without partition table can be error if it is supported and expected
use case. Error for me is if there is partition table, but we cannot
read it, it is corrupted, etc. but not in expected scenario.

Having a string with 1000 characters is supported. Still, if you
have a string with only 100 characters and you request the 200st
character you will cause an exception.

It's the same with the device graph in libstorage. A disk can
have a partition table or a filesystem (or something else) as a
child. Requesting the filesystem if the child is not a filesystem
raises an exception (as explained above).

But this discussion is once again unfruitful. In programming it
is not black and white. Those that implement something have to
find one way, others would have found other ways.


Arvin Schnell, <aschnell@xxxxxxxx>
Senior Software Engineer, Research & Development
SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284
(AG Nürnberg)
Maxfeldstraße 5
90409 Nürnberg
To unsubscribe, e-mail: yast-devel+unsubscribe@xxxxxxxxxxxx
To contact the owner, e-mail: yast-devel+owner@xxxxxxxxxxxx

< Previous Next >