本文整理了Java中java.lang.Error.getCause()
方法的一些代码示例,展示了Error.getCause()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Error.getCause()
方法的具体详情如下:
包路径:java.lang.Error
类名称:Error
方法名:getCause
暂无
代码示例来源:origin: aws/aws-sdk-java
@Override
public Error getCause() {
return (Error) super.getCause();
}
}
代码示例来源:origin: apache/geode
if (e.getCause() instanceof IOException) {
代码示例来源:origin: checkstyle/checkstyle
@Test
public void testCatchErrorInProcessFilesMethod() throws Exception {
// The idea of the test is to satisfy coverage rate.
// An Error indicates serious problems that a reasonable application should not try to
// catch, but due to issue https://github.com/checkstyle/checkstyle/issues/2285
// we catch errors in 'processFiles' method. Most such errors are abnormal conditions,
// that is why we use PowerMockito to reproduce them.
final File mock = PowerMockito.mock(File.class);
// Assume that I/O error is happened when we try to invoke 'lastModified()' method.
final String errorMessage = "Java Virtual Machine is broken"
+ " or has run out of resources necessary for it to continue operating.";
final Error expectedError = new IOError(new InternalError(errorMessage));
when(mock.lastModified()).thenThrow(expectedError);
final Checker checker = new Checker();
final List<File> filesToProcess = new ArrayList<>();
filesToProcess.add(mock);
try {
checker.process(filesToProcess);
fail("IOError is expected!");
}
// -@cs[IllegalCatchExtended] Testing for catch Error is part of 100% coverage.
catch (Error error) {
assertThat("Error cause differs from IOError",
error.getCause(), instanceOf(IOError.class));
assertThat("Error cause is not InternalError",
error.getCause().getCause(), instanceOf(InternalError.class));
assertEquals("Error message is not expected",
errorMessage, error.getCause().getCause().getMessage());
}
}
代码示例来源:origin: dremio/dremio-oss
@Override
public synchronized SQLException getCause() {
return (SQLException) super.getCause();
}
代码示例来源:origin: com.ibm.cos/ibm-cos-java-sdk-test-utils
@Override
public Error getCause() {
return (Error) super.getCause();
}
}
代码示例来源:origin: jp.dodododo/samurai-dao
@Override
public SQLException getCause() {
return (SQLException) super.getCause();
}
代码示例来源:origin: anba/es6draft
/**
* 13.14 The try Statement
*
* @param e
* the error cause
* @return if either <var>e</var> or its cause is a stack overflow error, that error object
* @throws Error
* if neither the error nor its cause is a stack overflow error
*/
public static StackOverflowError stackOverflowError(Error e) throws Error {
if (e instanceof StackOverflowError) {
return (StackOverflowError) e;
}
if (e instanceof BootstrapMethodError) {
Throwable cause = e.getCause();
if (cause instanceof StackOverflowError) {
return (StackOverflowError) cause;
}
}
throw e;
}
代码示例来源:origin: aws/aws-sdk-java-v2
@Override
public Error getCause() {
return Validate.isInstanceOf(Error.class, super.getCause(), "Unexpected cause type.");
}
}
代码示例来源:origin: software.amazon.awssdk/test-utils
@Override
public Error getCause() {
return Validate.isInstanceOf(Error.class, super.getCause(), "Unexpected cause type.");
}
}
代码示例来源:origin: org.ceylon-lang/ceylon.language
@Override
@Ignore
public java.lang.Throwable getCause() {
return super.getCause();
}
代码示例来源:origin: org.webpieces/core-channelmanager2
private void bindImpl(SocketAddress addr) throws IOException {
try {
bindImpl2(addr);
} catch(Error e) {
//NOTE: jdk was throwing Error instead of BindException. We fix
//this and throw BindException which is the logical choice!!
//We are crossing our fingers hoping there are not other SocketExceptions
//from things other than address already in use!!!
if(e.getCause() instanceof SocketException) {
BindException exc = new BindException(e.getMessage());
exc.initCause(e.getCause());
throw exc;
}
throw e;
}
}
代码示例来源:origin: org.appdapter/org.appdapter.lib.gui
@Override public Throwable getCause() {
if (true)
new MineField(e.getMessage(), e);
rethrowThisMaybe();
return super.getCause();
}
代码示例来源:origin: org.bidib.jbidib/jbidibc-spsw
@Override
public List<String> getPortIdentifiers() {
List<String> portIdentifiers = new ArrayList<>();
try {
// get the comm port identifiers
portIdentifiers.addAll(serialPortFactory.getPortNames(true));
}
catch (UnsatisfiedLinkError ule) {
LOGGER.warn("Get comm port identifiers failed.", ule);
throw new InvalidLibraryException(ule.getMessage(), ule.getCause());
}
catch (Error error) {
LOGGER.warn("Get comm port identifiers failed.", error);
throw new RuntimeException(error.getMessage(), error.getCause());
}
return portIdentifiers;
}
代码示例来源:origin: net.serenity-bdd/core
/**
* Will poll the interface on a regular basis until at least one element is present.
*/
public List<WebElement> findElements() {
if (aPreviousStepHasFailed()) {
return EMPTY_LIST_OF_WEBELEMENTS;
}
SlowLoadingElementList list = new SlowLoadingElementList(clock, annotatedTimeoutInSeconds.or(timeOutInSeconds));
try {
return list.get().getElements();
} catch (Error e) {
throw new NoSuchElementException(
String.format("Timed out after %d seconds. %s", annotatedTimeoutInSeconds.or(timeOutInSeconds), e.getMessage()),
e.getCause());
}
}
代码示例来源:origin: EvoSuite/evosuite
@Override
public synchronized Throwable getCause() {
if(!MockFramework.isEnabled()){
return super.getCause();
}
return getDelegate().getCause();
}
代码示例来源:origin: com.yahoo.vespa/application
private Application build() throws Exception {
Application app = null;
Exception exception = null;
// if we get a bind exception, then retry a few times (may conflict with parallel test runs)
for (int i = 0; i < 5; i++) {
try {
generateXml();
app = new Application(path, networking, true);
break;
} catch (Error e) { // the container thinks this is really serious, in this case is it not in the cause is a BindException
// catch bind error and reset container
Optional<BindException> bindException = Exceptions.findCause(e, BindException.class);
if (bindException.isPresent()) {
exception = bindException.get();
com.yahoo.container.Container.resetInstance(); // this is needed to be able to recreate the container from config again
} else {
throw new Exception(e.getCause());
}
}
}
if (app == null) {
throw exception;
}
return app;
}
代码示例来源:origin: net.serenity-bdd/serenity-core
/**
* Will poll the interface on a regular basis until at least one element is present.
*/
public List<WebElement> findElements() {
if (aPreviousStepHasFailed()) {
return EMPTY_LIST_OF_WEBELEMENTS;
}
SlowLoadingElementList list = new SlowLoadingElementList(clock, annotatedTimeoutInSeconds.orElse(getTimeOutInSeconds()));
try {
return list.get().getElements();
} catch (Error e) {
throw new NoSuchElementException(
String.format("Timed out after %d seconds. %s", annotatedTimeoutInSeconds.orElse(getTimeOutInSeconds()), e.getMessage()),
e.getCause());
}
}
代码示例来源:origin: terrier-org/terrier-core
public void write(final DataOutput out) throws IOException {
WritableUtils.writeVInt(out, getNumberOfPointers());
try
{
this.forEachTerm(new TObjectIntProcedure<String>()
{
public boolean execute(String term, int freq) {
try{
Text.writeString(out, term);
WritableUtils.writeVInt(out, freq);
} catch (IOException e) {
throw new Error(e);
}
return true;
}
});
} catch (Error e) {
throw (IOException)e.getCause();
}
}
代码示例来源:origin: org.pageseeder.ox/pso-ox-core
/**
* Returns the XML for a generic error.
*
* @param ex The error to turn to XML.
* @param xml The XML writer.
* @param wrap Whether to wrap the XML into an element.
*
* @throws IOException Only if thrown by the XML writer.
*/
private static void asErrorXML(Error ex, XMLWriter xml, boolean wrap) throws IOException {
if (wrap) {
xml.openElement("error");
}
xml.attribute("class", ex.getClass().getName());
xml.element("message", cleanMessage(ex));
xml.element("stack-trace", OXErrors.getStackTrace(ex, true));
Throwable cause = ex.getCause();
if (cause != null) {
xml.openElement("cause");
toXML(cause, xml, false);
xml.closeElement();
}
if (wrap) {
xml.closeElement();
}
}
代码示例来源:origin: org.netbeans.api/org-jruby
@JRubyMethod
public IRubyObject bind(IRubyObject host, IRubyObject port) {
InetSocketAddress addr = null;
try {
if (host.isNil()) {
addr = new InetSocketAddress(RubyNumeric.fix2int(port));
} else {
addr = new InetSocketAddress(InetAddress.getByName(host.convertToString().toString()), RubyNumeric.fix2int(port));
}
((DatagramChannel) this.getChannel()).socket().bind(addr);
return RubyFixnum.zero(this.getRuntime());
} catch (UnknownHostException e) {
throw sockerr(this, "bind: name or service not known");
} catch (SocketException e) {
throw sockerr(this, "bind: name or service not known");
} catch (Error e) {
// Workaround for a bug in Sun's JDK 1.5.x, see
// http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6303753
if (e.getCause() instanceof SocketException) {
throw sockerr(this, "bind: name or service not known");
} else {
throw e;
}
}
}
内容来源于网络,如有侵权,请联系作者删除!