未验证 提交 7e67358f 编写于 作者: H Hoshea Jiang 提交者: GitHub

Make the duration error message more specific (#5761)

* Make the duration error message more specific
上级 ac481e1b
......@@ -30,6 +30,8 @@ import org.joda.time.format.DateTimeFormatter;
public enum DurationUtils {
INSTANCE;
private static final int MAX_TIME_RANGE = 500;
private static final DateTimeFormatter YYYY_MM_DD = DateTimeFormat.forPattern("yyyy-MM-dd");
private static final DateTimeFormatter YYYY_MM_DD_HH = DateTimeFormat.forPattern("yyyy-MM-dd HH");
private static final DateTimeFormatter YYYY_MM_DD_HHMM = DateTimeFormat.forPattern("yyyy-MM-dd HHmm");
......@@ -119,9 +121,13 @@ public enum DurationUtils {
break;
}
i++;
if (i > 500) {
throw new UnexpectedException(
"Duration data error, step: " + step.name() + ", start: " + startTimeBucket + ", end: " + endTimeBucket);
if (i > MAX_TIME_RANGE) {
// days, hours, minutes or seconds
String stepStr = step.name().toLowerCase() + "s";
String errorMsg = String.format(
"Duration data error, the range between the start time and the end time can't exceed %d %s",
MAX_TIME_RANGE, stepStr);
throw new UnexpectedException(errorMsg);
}
}
while (endTimeBucket != durations.get(durations.size() - 1).getPoint());
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册