Side effects to creating but not throwing an exception

Discussion in 'Java' started by Rob, Jul 1, 2008.

  1. Rob

    Rob Guest

    Are there any side effects to creating but not throwing an exception?

    Thanks for your help,
    Rob
     
    Rob, Jul 1, 2008
    #1
    1. Advertising

  2. Rob wrote:
    > Are there any side effects to creating but not throwing an exception?
    >
    > Thanks for your help,
    > Rob


    About the same as creating any other object I would guess.

    Just for my curiosity, what are you really doing?

    --

    Knute Johnson
    email s/nospam/knute2008/

    --
    Posted via NewsDemon.com - Premium Uncensored Newsgroup Service
    ------->>>>>>http://www.NewsDemon.com<<<<<<------
    Unlimited Access, Anonymous Accounts, Uncensored Broadband Access
     
    Knute Johnson, Jul 1, 2008
    #2
    1. Advertising

  3. Rob

    Rob Guest

    On Jul 1, 4:12 pm, Knute Johnson <>
    wrote:
    > Rob wrote:
    > > Are there any side effects to creating but not throwing an exception?

    >
    > > Thanks for your help,
    > > Rob

    >
    > About the same as creating any other object I would guess.
    >
    > Just for my curiosity, what are you really doing?
    >
    > --
    >
    > Knute Johnson
    > email s/nospam/knute2008/
    >
    > --
    > Posted via NewsDemon.com - Premium Uncensored Newsgroup Service
    > ------->>>>>>http://www.NewsDemon.com<<<<<<------
    > Unlimited Access, Anonymous Accounts, Uncensored Broadband Access


    I have a set the exception message to a different value in one special
    case. I figured I could either pass a boolean through several calls
    to get to where the exception is thrown or I could examine the stack
    trace to see if a particular class is in the call stack which will
    tell me if I should change the exception message. It is an ugly hack,
    but probably the least unpleasant of several unpleasant alternatives.

    Thanks,
    Rob
     
    Rob, Jul 1, 2008
    #3
  4. Rob wrote:
    ....
    > I have a set the exception message to a different value in one special
    > case. I figured I could either pass a boolean through several calls
    > to get to where the exception is thrown or I could examine the stack
    > trace to see if a particular class is in the call stack which will
    > tell me if I should change the exception message. It is an ugly hack,
    > but probably the least unpleasant of several unpleasant alternatives.


    There is a third option. Throw a fixed exception based on what the
    method detecting the problem knows. Higher up the stack, at the level
    where you would be selecting the value of the boolean, catch it and
    throw a new exception, incorporating additional data or the changed
    message, with the original exception as its cause.

    Patricia
     
    Patricia Shanahan, Jul 1, 2008
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jim Bancroft
    Replies:
    2
    Views:
    2,472
    =?Utf-8?B?UmFodWwgQW5hbmQ=?=
    Dec 28, 2004
  2. Anonieko
    Replies:
    0
    Views:
    1,981
    Anonieko
    Aug 12, 2005
  3. VisionSet
    Replies:
    7
    Views:
    486
    Michael Rauscher
    Nov 9, 2004
  4. Jason Heyes
    Replies:
    10
    Views:
    555
    red floyd
    Dec 21, 2004
  5. Shan
    Replies:
    1
    Views:
    382
Loading...

Share This Page