/** * Creates a new exception for an error code, a detail message and a root cause. * * @param errorCode The code representing the erroneous outcome. * @param msg The detail message. * @param cause The root cause. * @throws IllegalArgumentException if the code is not ≥ 400 and < 600. */ public ServiceInvocationException(final int errorCode, final String msg, final Throwable cause) { super(providedOrDefaultMessage(errorCode, msg), cause); if (errorCode < 400 || errorCode >= 600) { throw new IllegalArgumentException(String.format("illegal error code [%d], must be >= 400 and < 600", errorCode)); } else { this.errorCode = errorCode; } }