com.gargoylesoftware.htmlunit.WebClient.isThrowExceptionOnFailingStatusCode()方法的使用及代码示例

x33g5p2x  于2022-02-02 转载在 其他  
字(3.1k)|赞(0)|评价(0)|浏览(125)

本文整理了Java中com.gargoylesoftware.htmlunit.WebClient.isThrowExceptionOnFailingStatusCode()方法的一些代码示例,展示了WebClient.isThrowExceptionOnFailingStatusCode()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WebClient.isThrowExceptionOnFailingStatusCode()方法的具体详情如下:
包路径:com.gargoylesoftware.htmlunit.WebClient
类名称:WebClient
方法名:isThrowExceptionOnFailingStatusCode

WebClient.isThrowExceptionOnFailingStatusCode介绍

[英]Returns true if an exception will be thrown in the event of a failing response code.
[中]如果响应代码失败时将引发异常,则返回true。

代码示例

代码示例来源:origin: org.jenkins-ci/htmlunit

/**
 * <span style="color:red">INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.</span>
 *
 * <p>Throws a {@link FailingHttpStatusCodeException} if the request's status code indicates a request
 * failure and {@link #isThrowExceptionOnFailingStatusCode()} returns <tt>true</tt>.
 *
 * @param webResponse the response which may trigger a {@link FailingHttpStatusCodeException}
 */
public void throwFailingHttpStatusCodeExceptionIfNecessary(final WebResponse webResponse) {
  final int statusCode = webResponse.getStatusCode();
  final boolean successful = (statusCode >= HttpStatus.SC_OK && statusCode < HttpStatus.SC_MULTIPLE_CHOICES)
    || statusCode == HttpStatus.SC_USE_PROXY
    || statusCode == HttpStatus.SC_NOT_MODIFIED;
  if (isThrowExceptionOnFailingStatusCode() && !successful) {
    throw new FailingHttpStatusCodeException(webResponse);
  }
}

代码示例来源:origin: net.disy.htmlunit/htmlunit

/**
 * <span style="color:red">INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.</span>
 *
 * <p>Throws a {@link FailingHttpStatusCodeException} if the request's status code indicates a request
 * failure and {@link #isThrowExceptionOnFailingStatusCode()} returns <tt>true</tt>.
 *
 * @param webResponse the response which may trigger a {@link FailingHttpStatusCodeException}
 */
public void throwFailingHttpStatusCodeExceptionIfNecessary(final WebResponse webResponse) {
  final int statusCode = webResponse.getStatusCode();
  final boolean successful = (statusCode >= HttpStatus.SC_OK && statusCode < HttpStatus.SC_MULTIPLE_CHOICES)
    || statusCode == HttpStatus.SC_USE_PROXY
    || statusCode == HttpStatus.SC_NOT_MODIFIED;
  if (isThrowExceptionOnFailingStatusCode() && !successful) {
    throw new FailingHttpStatusCodeException(webResponse);
  }
}

代码示例来源:origin: org.jvnet.hudson/htmlunit

/**
 * <span style="color:red">INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.</span>
 *
 * <p>Throws a {@link FailingHttpStatusCodeException} if the request's status code indicates a request
 * failure and {@link #isThrowExceptionOnFailingStatusCode()} returns <tt>true</tt>.
 *
 * @param webResponse the response which may trigger a {@link FailingHttpStatusCodeException}
 */
public void throwFailingHttpStatusCodeExceptionIfNecessary(final WebResponse webResponse) {
  final int statusCode = webResponse.getStatusCode();
  final boolean successful = (statusCode >= HttpStatus.SC_OK && statusCode < HttpStatus.SC_MULTIPLE_CHOICES)
    || statusCode == HttpStatus.SC_USE_PROXY
    || statusCode == HttpStatus.SC_NOT_MODIFIED;
  if (isThrowExceptionOnFailingStatusCode() && !successful) {
    throw new FailingHttpStatusCodeException(webResponse);
  }
}

相关文章

WebClient类方法