title: Android and IllegalStateException
body: <p>Would it be valid for me to throw an <code>IllegalStateException</code> in my Android application if I am executing a chunk of code that requires a number of variables not to be null, e.g. in the content provider <code>delete()</code> function I have: </p>
  
  <pre><code>public int delete(Uri uri, String where, String[] whereArgs) {
      try {
          SQLiteDatabase db = mOpenHelper.getWritableDatabase();
          int count;
          switch (sUriMatcher.match(uri)) {
              case NOTES:
                  count = db.delete(NOTES_TABLE_NAME, where, whereArgs);
                  break;
  
              case NOTE_ID:
                  String noteId = uri.getPathSegments().get(1);
                  count = db.delete(NOTES_TABLE_NAME, NoteColumns._ID + "=" + noteId
                      + (!TextUtils.isEmpty(where) ? " AND (" + where + ')' : ""), whereArgs);
                  break;
  
              default:
                 throw new IllegalArgumentException("Unknown URI " + uri);
         }
  
         getContext().getContentResolver().notifyChange(uri, null);
         return count;
  
      } catch (NullPointerException e) {
         // We really shouldn't get any null pointers!
         throw new IllegalStateException();
      }
  }
  </code></pre>
  
  <p>Because, although highly unlikely, there is a small chance that the following variables could be NULL:</p>
  
  <pre><code>- mOpenHelper
  - db
  - getContext()
  - getContentResolver()
  </code></pre>
  
  <p>Or is this an abuse of <code>IllegalStateException</code>? The reason I want to do this is because to me it seems wrong for this function to just throw <code>NullPointerExceptions</code>?</p>