public class ServiceRuntimeException extends RuntimeException {
private static final long serialVersionUID = -7610488146748705981L;
@Getter
private transient ResultCode resultCode;
public ServiceRuntimeException(ResultCode resultCode) {
super(resultCode.getMessage());
this.resultCode = resultCode;
}
public ServiceRuntimeException(ResultCode resultCode, String message) {
super(message);
this.resultCode = resultCode;
}
public ServiceRuntimeException(ResultCode resultCode, Throwable cause) {
super(resultCode.getMessage(), cause);
this.resultCode = resultCode;
}
public ServiceRuntimeException(ResultCode resultCode, String message, Throwable cause) {
super(message, cause);
this.resultCode = resultCode;
}
public static ServiceRuntimeException build(ResultCode resultCode, Object... args) {
return new ServiceRuntimeException(resultCode, MessageFormat.format(resultCode.getMessage(), args));
}
public static ServiceRuntimeException build(ResultCode resultCode, Throwable cause, Object... args) {
return new ServiceRuntimeException(resultCode, MessageFormat.format(resultCode.getMessage(), args), cause);
}
public static ServiceRuntimeException build(ResultCode resultCode, String message, Object... args) {
return new ServiceRuntimeException(resultCode, MessageFormat.format(message, args));
}