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 09:21:26AM +0100, Ladislav Slezak wrote:
Dne 24.11.2015 v 16:45 Josef Reidinger napsal(a):
On Tue, 24 Nov 2015 15:47:24 +0100
Stefan Hundhammer <shundhammer@xxxxxxx> wrote:
[...]
I have to do different things. To stay with the current example: A
disk might have

- an old-style MS-DOS type partition table with 4 slots (where I need
to use an extended partition if I need any more partitions)

- a new style GPT partition table that can have any number of
parititions

- a filesystem directly on the disk device without any partition table

So for me I can see it as three types of partition table - msdos, gpt
and no. I do not see why is better to have

begin
if gpt?
elsif msdos?
end
rescue
# no partition table case
end

If no partition is a valid use case (and it is as mentioned above) then it
does
not make sense to raise exception in that case. Exceptions should be used only
in error cases to handle *unexpected* things...

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.

Regards,
Arvin

--
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
Germany
--
To unsubscribe, e-mail: yast-devel+unsubscribe@xxxxxxxxxxxx
To contact the owner, e-mail: yast-devel+owner@xxxxxxxxxxxx

< Previous Next >
Follow Ups
References