New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Backtrace for java exceptions. #661
Comments
Sorry, I'm not quite following. Are you using the airbrake gem (this repo) with JRuby or are you using our Java Notifier (https://github.com/airbrake/airbrake-java)? |
I am using java notifier <dependency>
<groupId>io.airbrake</groupId>
<artifactId>airbrake-java</artifactId>
<version>2.2.8</version>
</dependency>
try {
method();
}
catch(Throwable t) {
Map<String, Object> errorMessages = new HashMap<>();
AirbrakeNotice notice = new AirbrakeNotice("key",
"twago-dev", "dev",
"errorMessage", "errorClass", new Backtrace(
Lists.newArrayList("java.lang.RuntimeException"," at TestException.method(TestException.java:19)"," at TestException.main(TestException.java:25)")),
Collections.<String, Object> emptyMap(),
Collections.<String, Object> emptyMap(), errorMessages,
Collections.<String> emptyList(), true, "errorUrl", "component");
AirbrakeNotifier notifier = new AirbrakeNotifier("http://api.airbrake.io/notifier_api/v2/notices");
notifier.notify(notice);
}
} The idea is when I send backtrace with this values java.lang.RuntimeException
at TestException.method(TestException.java:19)
at TestException.main(TestException.java:25) airbrake shows backtrace in this way java.lang.RuntimeException:-1 in java.lang.RuntimeException
TestException.java:19 in at TestException.method
TestException.java:25 in at TestException.main |
I see. This repository is for our Ruby notifier. Would you mind posting this issue to https://github.com/airbrake/airbrake-java ? I can do that myself, if you prefer. |
Ok, you are right, the problem is in Java Notifier public BacktraceLine(String line) {
String classAndMethodName = line.replaceAll("\\(.*", "").replaceAll("^at ", "");
int periodSepIndex = classAndMethodName.lastIndexOf(".");
if (periodSepIndex > 0) {
className = classAndMethodName.substring(0, classAndMethodName.lastIndexOf("."));
} else {
className = classAndMethodName;
}
fileName = fileName(line);
lineNumber = lineNumber(line);
methodName = methodName(classAndMethodName);
} |
On the second thought, I think the problem is on how airbrake represents stack trace. <backtrace>
<line method="java.lang.RuntimeException this is an error" file="java.lang.RuntimeException this is an error"
number="-1" />
<line method=" at TestAirbrake.method" file="TestAirbrake.java"
number="19" />
<line method=" at TestAirbrake.main" file="TestAirbrake.java"
number="25" />
</backtrace>
and airbrake represents this information in the same format, instead of reformatting it to the java style. |
I am a java developer, and I am using airbrake in a java project.
I don't understand why, but airbrake transforms java stack frames into the format, which is not very useful for java developers.
For example I have stack frames
In a console or a log file it would look like
When I have an exception like this one, I can copy it to a java IDE stack trace console and access any code line from this stack trace.
But in airbrake backtrace looks like
Java IDEs don't support this format.
The text was updated successfully, but these errors were encountered: