void () { String causeMsg = "failed to find target current"; RuntimeException rootCause = new IllegalStateException(causeMsg); String locationMsg = "Build file '~/project/build.gradle' line: 86"; RuntimeException locationError = new RuntimeException(locationMsg, rootCause) { @NotNull @Override public String toString() { return LocationAwareException.class.getName() + ": " + super.toString(); } }; Throwable error = new Throwable(locationError); RuntimeException realCause = myErrorHandler.getUserFriendlyError(null, error, myProjectPath, null); assertTrue(realCause instanceof LocationAwareExternalSystemException); LocationAwareExternalSystemException locationAwareExternalSystemException = (LocationAwareExternalSystemException)realCause; assertEquals("~/project/build.gradle", locationAwareExternalSystemException.getFilePath()); assertEquals(Integer.valueOf(-1), locationAwareExternalSystemException.getColumn()); assertEquals(Integer.valueOf(86), locationAwareExternalSystemException.getLine()); }