Skip to content

Commit

Permalink
Better error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcinMoskala committed Feb 14, 2017
1 parent fa93380 commit 1b753e9
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ internal inline fun <reified T : Any> String.fromJson() = fromJson(T::class)

internal fun <T : Any> String.fromJson(clazz: KClass<T>) = try {
preferencesGson.fromJson(this, clazz.java)
} catch (e: JsonSyntaxException) {
throw Error("Error in parsing \"$this\" to ${clazz.java}", e)
} catch (e: Throwable) {
throw Error("Error in parsing to ${clazz.java}. Possibly lack of gson serializers. The string to parse: \"$this\"", e)
}

0 comments on commit 1b753e9

Please sign in to comment.