Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 848485bb authored by Fyodor Kupolov's avatar Fyodor Kupolov
Browse files

List column names in the error message

Otherwise it's not clear what is causing the issue (e.g. no columns,
case sensitivity issue or a table prefix etc.)

Bug: 62431773
Test: manual
Change-Id: I81d1f420b70a2248a9b132147cda72c2417dc46b
parent d294d8dc
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ import android.os.UserHandle;
import android.util.Log;

import java.lang.ref.WeakReference;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;

@@ -330,7 +331,14 @@ public abstract class AbstractCursor implements CrossProcessCursor {
    public int getColumnIndexOrThrow(String columnName) {
        final int index = getColumnIndex(columnName);
        if (index < 0) {
            throw new IllegalArgumentException("column '" + columnName + "' does not exist");
            String availableColumns = "";
            try {
                availableColumns = Arrays.toString(getColumnNames());
            } catch (Exception e) {
                Log.d(TAG, "Cannot collect column names for debug purposes", e);
            }
            throw new IllegalArgumentException("column '" + columnName
                    + "' does not exist. Available columns: " + availableColumns);
        }
        return index;
    }