-
Notifications
You must be signed in to change notification settings - Fork 1k
/
QueryError.java
51 lines (39 loc) · 1.27 KB
/
QueryError.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package org.graylog.plugins.enterprise.search.errors;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.apache.commons.lang.exception.ExceptionUtils;
import org.graylog.plugins.enterprise.search.Query;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import static org.graylog2.shared.utilities.ExceptionUtils.getRootCauseMessage;
public class QueryError implements SearchError {
private final Query query;
@Nullable
private final Throwable throwable;
private final String description;
public QueryError(@Nonnull Query query, Throwable throwable) {
this.query = query;
this.throwable = throwable;
this.description = getRootCauseMessage(throwable);
}
public QueryError(@Nonnull Query query, String description) {
this.query = query;
this.description = description;
this.throwable = null;
}
@JsonProperty("query_id")
public String queryId() {
return query.id();
}
@Override
public String description() {
return description;
}
@Nullable
@JsonProperty("backtrace")
public String backtrace() {
if (throwable == null) {
return null;
}
return ExceptionUtils.getFullStackTrace(throwable);
}
}