|
24 | 24 | import android.net.Uri; |
25 | 25 | import android.support.annotation.NonNull; |
26 | 26 |
|
| 27 | +import com.crashlytics.android.Crashlytics; |
| 28 | + |
27 | 29 | import org.gnucash.android.R; |
28 | 30 | import org.gnucash.android.app.GnuCashApplication; |
29 | 31 | import org.gnucash.android.db.DatabaseSchema.BookEntry; |
@@ -155,15 +157,32 @@ public boolean isActive(String bookUID){ |
155 | 157 | Cursor cursor = mDb.query(mTableName, new String[]{BookEntry.COLUMN_UID}, |
156 | 158 | BookEntry.COLUMN_ACTIVE + "= 1", null, null, null, null, "1"); |
157 | 159 | try{ |
158 | | - if (cursor.getCount() == 0) |
159 | | - throw new NoActiveBookFoundException("There is no active book in the app. This should NEVER happen, fix your bugs!"); |
| 160 | + if (cursor.getCount() == 0) { |
| 161 | + NoActiveBookFoundException e = new NoActiveBookFoundException( |
| 162 | + "There is no active book in the app." |
| 163 | + + "This should NEVER happen, fix your bugs!\n" |
| 164 | + + getNoActiveBookFoundExceptionInfo()); |
| 165 | + Crashlytics.logException(e); |
| 166 | + throw e; |
| 167 | + } |
160 | 168 | cursor.moveToFirst(); |
161 | 169 | return cursor.getString(cursor.getColumnIndexOrThrow(BookEntry.COLUMN_UID)); |
162 | 170 | } finally { |
163 | 171 | cursor.close(); |
164 | 172 | } |
165 | 173 | } |
166 | 174 |
|
| 175 | + private String getNoActiveBookFoundExceptionInfo() { |
| 176 | + StringBuilder info = new StringBuilder("UID, created, source\n"); |
| 177 | + for (Book book : getAllRecords()) { |
| 178 | + info.append(String.format("%s, %s, %s\n", |
| 179 | + book.getUID(), |
| 180 | + book.getCreatedTimestamp(), |
| 181 | + book.getSourceUri())); |
| 182 | + } |
| 183 | + return info.toString(); |
| 184 | + } |
| 185 | + |
167 | 186 | public class NoActiveBookFoundException extends RuntimeException { |
168 | 187 | public NoActiveBookFoundException(String message) { |
169 | 188 | super(message); |
|
0 commit comments