public inbox for frysk@sourceware.org
 help / color / mirror / Atom feed
From: Kris Van Hees <kris.van.hees@oracle.com>
To: Sami Wagiaalla <swagiaal@redhat.com>
Cc: Mark Wielaard <mark@klomp.org>,
	Phil Muldoon <pmuldoon@redhat.com>,
	        frysk@sourceware.org
Subject: Re: fhpd vs RuntimeExceptions
Date: Thu, 15 Nov 2007 20:33:00 -0000	[thread overview]
Message-ID: <20071115203139.GB17388@oracle.com> (raw)
In-Reply-To: <473C8E08.3070305@redhat.com>

On Thu, Nov 15, 2007 at 01:20:56PM -0500, Sami Wagiaalla wrote:
> Mark Wielaard wrote:
>> By using different exception types, so a higher level can distinquish
>> between a "recoverable" warning and a "unrecoverable" error.
>>   
> My suggestion would be to create a MetaDataTablePeekFailedException. 
> Recoverable or unrecoverable is not something that the thrower can decide, 
> it is the decision of the catcher. For example DwAttributeNotFoundException 
> can be used to conclude something about a die's type. But in another case 
> it can mean that your code is looking for a bogus attribute or is looking 
> at the wrong die. If your code knows why the exception is thrown then by 
> all means handle it, print a clean stack trace free error/warning message 
> or nothing at all. Otherwise let it float up.

Well, yes and no.  From the perspective of the thrower there can definitely be
a determination on whether a problem is persistent or temporary, i.e. whether
the operation can be retried.  Likewise, the thrower may be able to indicate in
the exception whether there may be an alternative resolution (but leaving the
decision on whether that is used to the caller).  That's a less common way to
use exceptions, but it definitely has its uses.

The caller can have its own decision logic on how to handle exceptions.  E.g.
it is very well possible that the thrower considers a problem persistent, while
the caller knows some alternatives to try.  Looking for a file in different
locations is a typical example of that.  The thrower will typically indicate
that the given file (specified with an absolute path) cannot be accessed, while
the caller may have a couple of directories left to try.

One common problem with exceptions that I keep running into with projects is
overuse of letting exceptions float up until someone handles it.  More often
than not, exceptions end up floating across component boundaries.  In those
cases, it might be more appropriate to catch the exception, and throw a new
one (using the caught one as reason) to indicate the exception status on the
level of the current component.

	Cheers,
	Kris

  reply	other threads:[~2007-11-15 20:33 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-11-14 14:27 Mark Wielaard
2007-11-14 14:45 ` Andrew Cagney
2007-11-14 15:27   ` Kris Van Hees
2007-11-14 15:36   ` Mark Wielaard
2007-11-14 17:33     ` Andrew Cagney
2007-11-14 19:11       ` Mark Wielaard
2007-11-15 17:01 ` Phil Muldoon
2007-11-15 17:42   ` Mark Wielaard
2007-11-15 18:19     ` Phil Muldoon
2007-11-15 18:25       ` Sami Wagiaalla
2007-11-16 11:21       ` Mark Wielaard
2007-11-15 18:21     ` Sami Wagiaalla
2007-11-15 20:33       ` Kris Van Hees [this message]
2007-11-16 10:12       ` Mark Wielaard
2007-11-15 18:46     ` Andrew Cagney
2007-11-16 10:15       ` Mark Wielaard
2007-11-15 20:41     ` Kris Van Hees
2007-11-15 22:11       ` Phil Muldoon
2007-11-15 23:09         ` Kris Van Hees
2007-11-16 10:42       ` Mark Wielaard
2007-11-15 18:04   ` Mark Wielaard
2007-11-15 18:22     ` Phil Muldoon
2007-11-15 19:06     ` Andrew Cagney
2007-11-16 10:28       ` Mark Wielaard
2007-11-16 14:32         ` Andrew Cagney
2007-11-26 10:18           ` Mark Wielaard

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20071115203139.GB17388@oracle.com \
    --to=kris.van.hees@oracle.com \
    --cc=frysk@sourceware.org \
    --cc=mark@klomp.org \
    --cc=pmuldoon@redhat.com \
    --cc=swagiaal@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).