google / ground-android

Ground mobile data collection app for Android
http://groundplatform.org
Apache License 2.0
244 stars 115 forks source link

[Code health] Revisit use of Exceptions and Nullable Types #2216

Open scolsen opened 8 months ago

scolsen commented 8 months ago

There are a few places in the code base where we currently throw exceptions that we might be able to convert to nullable return values or Kotlin's Result type instead, for example, in the SubmissionConverter.

We should do a pass to see if there are any cases in which we're overusing exceptions, or not using exceptions for cases that really are exceptional.

See https://github.com/google/ground-android/pull/2214#discussion_r1475224703 for additional context.

gino-m commented 8 months ago

Once case where this might be used is in converter logic; converters could return Result rather than an exception so that there are compile-checks to ensure coroutines and Flows handle them correctly. See also https://github.com/google/ground-platform/issues/931.