Laur's blog
  • Home
  • About
  • Support my work
Sign in Subscribe

exception

A collection of 3 posts
Don't Use Assert() If You Don't Mean It (C++)
c++ assert

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

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 LOGIC_ERROR(condition) macro: #define LOGIC_ERROR(e) if(!(e)) throw std:
Dec 26, 2015 1 min read
About Java Exceptions in SE 7
7

About Java Exceptions in SE 7

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: try { // Some reflective stuff ... } catch(ReflectiveOperationException e)
Nov 7, 2015 1 min read
NullPointerException - getInstrumentation().getContext()
android

NullPointerException - getInstrumentation().getContext()

Here's a beginner mistake... The following code: public class ReactiveApiTest extends InstrumentationTestCase { protected LocalJsonClient mLocalJsonClient; public ReactiveApiTest() { super(); mLocalJsonClient = new LocalJsonClient( getInstrumentation().getContext() ); } // ... } Throws an exception: Attempt to invoke virtual method 'android.content.Context android.app.Instrumentation.getContext()' on a null object reference It to
Mar 11, 2015 1 min read
Page 1 of 1
Laur's blog © 2025
  • Sign up
Powered by Ghost