Skip to content

Commit

Permalink
error handling on quantile values
Browse files Browse the repository at this point in the history
  • Loading branch information
squito committed Apr 1, 2015
1 parent b2efcaf commit ad27de8
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -140,3 +140,16 @@ private[v1] class NotFoundException(msg: String) extends WebApplicationException
.entity(msg)
.build()
)

private[v1] class BadParameterException(msg: String) extends WebApplicationException(
new IllegalArgumentException(msg),
Response
.status(Response.Status.BAD_REQUEST)
.entity(msg)
.build()
) {
def this(param: String, exp: String, actual: String) = {
this("Bad value for parameter \"" + param + "\". Expected a " + exp + ", got \"" +
actual + "\"")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,14 @@ private[v1] class OneStageResource(uiRoot: UIRoot) {
stageInfo.stageId + ":" + stageInfo.attemptId)
)
}
//TODO error handling
val quantiles = quantileString.split(",").map{_.toDouble}
println("quantiles = " + quantiles.mkString(","))
val quantiles = quantileString.split(",").map{s =>
try {
s.toDouble
} catch {
case nfe: NumberFormatException =>
throw new BadParameterException("quantiles", "double", s)
}
}
AllStagesResource.taskMetricDistributions(stageUiData.taskData.values, quantiles)
}
}
Expand Down

0 comments on commit ad27de8

Please sign in to comment.