1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 package org.opencastproject.graphql.exception;
23
24 import java.util.List;
25 import java.util.Map;
26
27 import graphql.ErrorClassification;
28 import graphql.GraphQLError;
29 import graphql.language.SourceLocation;
30
31 public class GraphQLRuntimeException extends RuntimeException implements GraphQLError {
32 private static final long serialVersionUID = 7752209655703366697L;
33
34 private final OpencastErrorType errorType;
35 private Map<String,Object> extensions;
36
37 public GraphQLRuntimeException(OpencastErrorType errorType) {
38 this.errorType = errorType;
39 }
40
41 public GraphQLRuntimeException(String message, OpencastErrorType errorType) {
42 super(message);
43 this.errorType = errorType;
44 }
45
46 public GraphQLRuntimeException(String message, OpencastErrorType errorType, Throwable cause) {
47 super(message, cause);
48 this.errorType = errorType;
49 }
50
51 public GraphQLRuntimeException(String message, Map<String,Object> extensions, Throwable cause) {
52 super(message, cause);
53 this.errorType = OpencastErrorType.Undefined;
54 this.extensions = extensions;
55 }
56
57 public GraphQLRuntimeException(String message, OpencastErrorType errorType, Map<String,Object> extensions,
58 Throwable cause) {
59 super(message, cause);
60 this.errorType = errorType;
61 this.extensions = extensions;
62 }
63
64 public GraphQLRuntimeException(Throwable cause) {
65 super(cause);
66 this.errorType = OpencastErrorType.InternalError;
67 }
68
69 public GraphQLRuntimeException(OpencastErrorType errorType, Throwable cause) {
70 super(cause);
71 this.errorType = errorType;
72 }
73
74 @Override
75 public List<SourceLocation> getLocations() {
76 return null;
77 }
78
79 public ErrorClassification getErrorType() {
80 return errorType;
81 }
82
83 @Override
84 public List<Object> getPath() {
85 return GraphQLError.super.getPath();
86 }
87
88 @Override
89 public Map<String, Object> toSpecification() {
90 return GraphQLError.super.toSpecification();
91 }
92
93 public Map<String, Object> getExtensions() {
94 return extensions;
95 }
96
97 }