Commit a1f91b0f authored by Michael Droettboom's avatar Michael Droettboom
Browse files

Use "val X = try {" syntax

parent 697d91dd
......@@ -191,9 +191,8 @@ data class TimingDistributionData(
return null
}
val rawHistogramType = jsonObject.tryGetString("histogram_type") ?: return null
var histogramType: HistogramType
try {
histogramType = HistogramType.valueOf(rawHistogramType.capitalize())
val histogramType = try {
HistogramType.valueOf(rawHistogramType.capitalize())
} catch (e: IllegalArgumentException) {
return null
}
......@@ -212,9 +211,8 @@ data class TimingDistributionData(
}
val sum = jsonObject.tryGetLong("sum") ?: return null
val rawTimeUnit = jsonObject.tryGetString("time_unit") ?: return null
var timeUnit: TimeUnit
try {
timeUnit = TimeUnit.valueOf(rawTimeUnit.capitalize())
val timeUnit = try {
TimeUnit.valueOf(rawTimeUnit.capitalize())
} catch (e: IllegalArgumentException) {
return null
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment