Propagates throwable as-is if it is an instance of RuntimeException or Error, or else as a last resort, wraps it in a RuntimeException then propagates.
This method always throws an exception. The RuntimeException return type is only for
client code to make Java type system happy in case a return value is required by the enclosing
method. Example usage:
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-28 UTC."],[],[],null,["# Class Throwables (2.0.0)\n\nVersion latestkeyboard_arrow_down\n\n- [2.0.0 (latest)](/java/docs/reference/google-http-client/latest/com.google.api.client.util.Throwables)\n- [1.47.1](/java/docs/reference/google-http-client/1.47.1/com.google.api.client.util.Throwables)\n- [1.46.3](/java/docs/reference/google-http-client/1.46.3/com.google.api.client.util.Throwables)\n- [1.45.3](/java/docs/reference/google-http-client/1.45.3/com.google.api.client.util.Throwables)\n- [1.44.2](/java/docs/reference/google-http-client/1.44.2/com.google.api.client.util.Throwables)\n- [1.43.2](/java/docs/reference/google-http-client/1.43.2/com.google.api.client.util.Throwables)\n- [1.42.3](/java/docs/reference/google-http-client/1.42.3/com.google.api.client.util.Throwables)\n- [1.41.8](/java/docs/reference/google-http-client/1.41.8/com.google.api.client.util.Throwables) \n\n public final class Throwables\n\nStatic utility methods pertaining to instances of [Throwable](https://docs.oracle.com/javase/8/docs/api/java/lang/Throwable.html).\n\nNOTE: proxy for the Guava implementation of com.google.common.base.Throwables. \n\nInheritance\n-----------\n\n[java.lang.Object](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html) \\\u003e Throwables \n\nInherited Members\n-----------------\n\n[Object.clone()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#clone--) \n[Object.equals(Object)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#equals-java.lang.Object-) \n[Object.finalize()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#finalize--) \n[Object.getClass()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#getClass--) \n[Object.hashCode()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#hashCode--) \n[Object.notify()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notify--) \n[Object.notifyAll()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notifyAll--) \n[Object.toString()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#toString--) \n[Object.wait()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait--) \n[Object.wait(long)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-) \n[Object.wait(long,int)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-int-)\n\nStatic Methods\n--------------\n\n### \\\u003cX\\\u003epropagateIfPossible(Throwable throwable, Class\\\u003cX\\\u003e declaredType)\n\n public static void \u003cX\u003epropagateIfPossible(Throwable throwable, Class\u003cX\u003e declaredType)\n\nPropagates `throwable` exactly as-is, if and only if it is an instance of [RuntimeException](https://docs.oracle.com/javase/8/docs/api/java/lang/RuntimeException.html), Error, or `declaredType`. Example usage:\n\ntry {\nsomeMethodThatCouldThrowAnything();\n} catch (IKnowWhatToDoWithThisException e) {\nhandle(e);\n} catch (Throwable t) {\nThrowables.propagateIfPossible(t, OtherException.class);\nthrow new RuntimeException(\"unexpected\", t);\n}\n\n### propagate(Throwable throwable)\n\n public static RuntimeException propagate(Throwable throwable)\n\nPropagates `throwable` as-is if it is an instance of [RuntimeException](https://docs.oracle.com/javase/8/docs/api/java/lang/RuntimeException.html) or Error, or else as a last resort, wraps it in a `RuntimeException` then propagates.\n\nThis method always throws an exception. The `RuntimeException` return type is only for\nclient code to make Java type system happy in case a return value is required by the enclosing\nmethod. Example usage:\n\nT doSomething() {\ntry {\nreturn someMethodThatCouldThrowAnything();\n} catch (IKnowWhatToDoWithThisException e) {\nreturn handle(e);\n} catch (Throwable t) {\nthrow Throwables.propagate(t);\n}\n}\n\n### propagateIfPossible(Throwable throwable)\n\n public static void propagateIfPossible(Throwable throwable)\n\nPropagates `throwable` exactly as-is, if and only if it is an instance of [RuntimeException](https://docs.oracle.com/javase/8/docs/api/java/lang/RuntimeException.html) or Error. Example usage:\n\ntry {\nsomeMethodThatCouldThrowAnything();\n} catch (IKnowWhatToDoWithThisException e) {\nhandle(e);\n} catch (Throwable t) {\nThrowables.propagateIfPossible(t);\nthrow new RuntimeException(\"unexpected\", t);\n}"]]