Re: [PATCH 12/22] Add exception handling classes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Mar 08, 2018 at 10:56:55AM +0100, Christophe de Dinechin wrote:
> > In many cases you want to add information to the exception and
> > is quite common to catch one exception, add another informations
> > and throw a more detailed exception.
> 
> It is useful, indeed. And when you need to do that, I strongly prefer something like:
> 
> catch (WriteError &we) {
> 	if (errno == EPERM) {
> 		collect_SELinuxData(&sedata);
> 		throw WriteErrorWithSELinuxData(we, sedata);
> 	}
> }
> 
> which I find vastly superior to an alternative like:
> 
> catch (some_runtime_error &e) {
> 	if (parse_what_looking_for_errno(e.what()) == EPERM) {
> 		collect_SELinuxData(&sedata);
> 		throw some_runtime_error(e.what() + “ with SELinux information “ + format_se_linux_info_as_string(sedata));
> }

I believe you are missing the point, right now the discussion is not
about the Exception hierarchy, the constructor API, ..., it's only about
the 'const char *' args to the constructor(s) having to be kept alive by
the caller rather than having the exception class taking care of this.

Once that is taken care of, there might be more discussion about the
structure of the exception hierarchy, which constructors we want, ...
but as of now, this is not the blocking point, so let's not diverge in
that discussion just yet.

Christophe

Attachment: signature.asc
Description: PGP signature

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel

[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]