• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NullPointerException
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NullPointerException


  • Subject: Re: NullPointerException
  • From: Farrukh Ijaz <email@hidden>
  • Date: Thu, 12 Apr 2012 21:25:53 +0300

Hi Ken,

Also we should not call toString() method on e.getCause() because it's not always necessary you get a cause if the exception is already at it's origin. Here is a sample code to test this:

Farrukh

public class ExceptionTest {

        public static void printCause(Throwable t) {
                System.err.println(t.toString());
                printCause(t.getCause());
        }

        public static void main(String[] args) {
                try {
                        throw new Exception("Testing");
                } catch(Exception e) {
                        printCause(e);
                }
        }
}

Farrukhs-MacBook-Pro:TopCoder fijaz$ java ExceptionTest
java.lang.Exception: Testing
Exception in thread "main" java.lang.NullPointerException
at ExceptionTest.printCause(ExceptionTest.java:4)
at ExceptionTest.printCause(ExceptionTest.java:5)
at ExceptionTest.main(ExceptionTest.java:12)


On 2012-04-12, at 9:08 PM, Ken Anderson wrote:

94 try{
95   System.out.println(editingContext.toString());
96   me.editingContext().saveChanges();
97 } catch (Exception e){
98   System.out.println(me._primaryKey);
99   System.out.println(editingContext.objectForGlobalID(me.__globalID()).valueForKey(ADDRESS1_KEY));
100   System.out.println(e.getCause().toString());

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >NullPointerException (From: Ken Anderson <email@hidden>)
 >Re: NullPointerException (From: Ken Anderson <email@hidden>)
 >Re: NullPointerException (From: Ken Anderson <email@hidden>)
 >Re: NullPointerException (From: Ken Anderson <email@hidden>)

  • Prev by Date: Re: Your JasperReport Example and D2W
  • Next by Date: Re: Website Hijacked
  • Previous by thread: Re: NullPointerException
  • Next by thread: How do I switch the parent page after submitting AMD
  • Index(es):
    • Date
    • Thread