PaulG
PaulG

Reputation: 7112

Why is my BlackBerry exception getMessage() returning null?

I'm using the following line of code in all of my catch statements to print errors to the console:

System.out.println("ERROR MESSAGE " + e.getMessage() );

Sometimes, in the console, I get the following:

ERROR MESSAGE null

How can it be null? If it reaches the catch that means an exception was thrown, but why null?

Upvotes: 5

Views: 350

Answers (1)

rosco
rosco

Reputation: 939

I don't know why it is null, I just suppose that BlackBerry OS and API has a lot of undesired behaviour. I solved this issue by using

e.toString()

as in:

catch (Exception e)
{    
    System.out.println("Exception caught: " + e.toString());
}

Upvotes: 6

Related Questions