英文:
How to wrap APIException message in array in one line in java
问题
我想要将抛出的异常写在一个数组的一行中,换句话说,我该如何将第一个抛出的异常包装成一个数组。
if (Books.size() == 1) {
throw new APIException("User.you.must.have.authority", new Object[] { requiredPrivs.get(0) });
} else if (Books.size() > 1) {
throw new APIException(String.format("User.you.must.have.privileges", String.join(", ", requiredPrivs)));
}
因此在这段代码中,我想要确保我在一个ArrayList行中格式化抛出的API异常,任何帮助都非常欢迎。
英文:
I would like to write the thrown exception in one line of an array, other words, how can I wrap the first thrown exception into an array.
if (Books.size() == 1) {
throw new APIException("User.you.must.have.authority", new Object[] { requiredPrivs.get(0) });
} else if (Books.size() > 1) {
throw new APIException(String.format("User.you.must.have.privileges", String.join(", ", requiredPrivs)));
}
so in this code, i want to make sure i format the thrown api exception in one arraylist line, any knda help is highly welcome
专注分享java语言的经验与见解,让所有开发者获益!
评论