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(Throwable cause) {
38 super(cause);
39 this.errorType = OpencastErrorType.InternalError;
40 }
41
42 public GraphQLRuntimeException(String message) {
43 super(message);
44 this.errorType = OpencastErrorType.InternalError;
45 }
46
47 public GraphQLRuntimeException(OpencastErrorType errorType) {
48 this.errorType = errorType;
49 }
50
51 public GraphQLRuntimeException(OpencastErrorType errorType, Throwable cause) {
52 super(cause);
53 this.errorType = errorType;
54 }
55
56 public GraphQLRuntimeException(String message, OpencastErrorType errorType) {
57 super(message);
58 this.errorType = errorType;
59 }
60
61 public GraphQLRuntimeException(String message, OpencastErrorType errorType, Throwable cause) {
62 super(message, cause);
63 this.errorType = errorType;
64 }
65
66 public GraphQLRuntimeException(String message, OpencastErrorType errorType, Map<String,Object> extensions) {
67 super(message);
68 this.errorType = errorType;
69 this.extensions = extensions;
70 }
71
72 public GraphQLRuntimeException(String message, OpencastErrorType errorType, Map<String,Object> extensions,
73 Throwable cause) {
74 super(message, cause);
75 this.errorType = errorType;
76 this.extensions = extensions;
77 }
78
79 public GraphQLRuntimeException(String message, Map<String,Object> extensions) {
80 super(message);
81 this.errorType = OpencastErrorType.Undefined;
82 this.extensions = extensions;
83 }
84
85 public GraphQLRuntimeException(String message, Map<String,Object> extensions, Throwable cause) {
86 super(message, cause);
87 this.errorType = OpencastErrorType.Undefined;
88 this.extensions = extensions;
89 }
90
91 @Override
92 public List<SourceLocation> getLocations() {
93 return null;
94 }
95
96 public ErrorClassification getErrorType() {
97 return errorType;
98 }
99
100 @Override
101 public List<Object> getPath() {
102 return GraphQLError.super.getPath();
103 }
104
105 @Override
106 public Map<String, Object> toSpecification() {
107 return GraphQLError.super.toSpecification();
108 }
109
110 public Map<String, Object> getExtensions() {
111 return extensions;
112 }
113
114 }