如何在Java中一行内将APIException消息包装成数组。

huangapple 未分类评论41阅读模式
英文:

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

huangapple
  • 本文由 发表于 2020年4月9日 05:07:52
  • 转载请务必保留本文链接:https://java.coder-hub.com/61110051.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定