I see what you mean about reproduce. I log the query that results in the
null, but that's not useful to us if it's not in the generated error
report. I'm thinking about adding an option to the report to let it have a
String included in the report -- in this case holding the query.


On Thu, May 8, 2014 at 10:05 PM, Nicolas Raoul <notifications@github.com>wrote:

> In src/com/ichi2/anki/AnkiDb.java:
>
> >              cursor = mDatabase.rawQuery(query, null);
> >              String methodName = getCursorMethodName(type.getSimpleName());
> >              while (cursor.moveToNext()) {
> > -                // The magical line. Almost as illegible as python code ;)
> > -                results.add(type.cast(Cursor.class.getMethod(methodName, int.class).invoke(cursor, column)));
> > +                try {
> > +                    // The magical line. Almost as illegible as python code ;)
> > +                    results.add(type.cast(Cursor.class.getMethod(methodName, int.class).invoke(cursor, column)));
> > +                } catch (InvocationTargetException e) {
> > +                    if (cursor.isNull(column)) { // null value encountered
> > +                        Log.w(AnkiDroidApp.TAG, "AnkiDb.queryColumn (column " + column + "): Located null during exception. Attempting to skip null result and continue. Query: " + query);
> > +                        AnkiDroidApp.saveExceptionReportFile(e, "queryColumn_encounteredNull");
> > +                        continue; // attempt to skip this null record
>
> The best would be to launch the feedback screen, to make it possible for
> the user to understand how to reproduce the bug, thus leading to a fix
> faster.
>
> —
> Reply to this email directly or view it on GitHub<https://github.com/ankidroid/Anki-Android/pull/341/files#r12464406>
> .
>