Closed JakeWharton closed 7 years ago
Yeah we should be trapping this and forwarding to onError. Malformed SQL should be sent through the normal error-handling pipeline.
On Sat, Jun 10, 2017, 1:22 PM Siim Kinks notifications@github.com wrote:
The SQLiteException is thrown when Query#run is called in RecordingObserver#onNext, but this is not allowed in RxJava2 since it's not a fatal exception, which results in process death.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/square/sqlbrite/issues/185#issuecomment-307578779, or mute the thread https://github.com/notifications/unsubscribe-auth/AAEEEW-AhUj4ApTcLMppJQ7DzGvFFzi3ks5sCtDYgaJpZM4Nvcg1 .
I don't see any actions to take here, since this particular case is a consumer problem.
Exception is handled correctly when used in operators:
@Test public void badQueryCallsErrorInOperator() {
TestObserver<Employee> o = db.createQuery(TABLE_EMPLOYEE, "SELECT * FROM missing")
.mapToOne(Employee.MAPPER)
.test();
o.awaitTerminalEvent();
final List<Throwable> errors = o.errors();
assertThat(errors).hasSize(1);
assertThat(errors.get(0).getMessage()).contains("no such table: missing");
}
Only thing we could do is inform users to use safeSubscribe
as described in What's-different-in-2.0#leaving-the-reactive-world
@Test public void badQueryCallsError() {
db.createQuery(TABLE_EMPLOYEE, "SELECT * FROM missing").safeSubscribe(o);
o.assertErrorContains("no such table: missing");
}
The SQLiteException is thrown when
Query#run
is called inRecordingObserver#onNext
, but this is not allowed in RxJava2 since it's not a fatal exception, which results in process death.