Skip to content

Content Tagged "exception"

Page 1 of 1

Don't Use Assert() If You Don't Mean It (C++)

December 26, 2015Category: Software
I found the hard way that assert() in C/C++ exists hard. This post explains that you get a SIGABRT . So, if you want your code to be testable, you better throw an exception instead. I defined a macro: So, in a code like this: You'll get an exception with the message "1 > 2" . Useful. You can…

About Java Exceptions in SE 7

November 7, 2015Category: Software
TL;DR : JDK 7 improves on exception handling (less code, base exception class...). Base exception class Reflective operations exceptions now have a base class ReflectiveOperationException. This allows you to to a global catch rather than one for each exception. Now you can write: Note : Reflective…

NullPointerException - getInstrumentation().getContext()

March 11, 2015Category: Software
Here's a beginner mistake... The following code: Throws an exception: Attempt to invoke virtual method 'android.content.Context' on a null object reference It took me some time to find out why: getInstrumentation() returns null in the constructor :) The…

All tags