Flutter Engine
The Flutter Engine
RequestError.java
Go to the documentation of this file.
1/*
2 * Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
3 * for details. All rights reserved. Use of this source code is governed by a
4 * BSD-style license that can be found in the LICENSE file.
5 *
6 * This file has been automatically generated. Please do not edit it manually.
7 * To regenerate the file, use the script "pkg/analysis_server/tool/spec/generate_files".
8 */
9package org.dartlang.analysis.server.protocol;
10
11import java.util.Arrays;
12import java.util.List;
13import java.util.Map;
14import com.google.common.collect.Lists;
15import com.google.dart.server.utilities.general.JsonUtilities;
16import com.google.dart.server.utilities.general.ObjectUtilities;
17import com.google.gson.JsonArray;
18import com.google.gson.JsonElement;
19import com.google.gson.JsonObject;
20import com.google.gson.JsonPrimitive;
21import org.apache.commons.lang3.builder.HashCodeBuilder;
22import java.util.ArrayList;
23import java.util.Iterator;
24import org.apache.commons.lang3.StringUtils;
25
26/**
27 * An indication of a problem with the execution of the server, typically in response to a request.
28 *
29 * @coverage dart.server.generated.types
30 */
31@SuppressWarnings("unused")
32public class RequestError {
33
34 public static final RequestError[] EMPTY_ARRAY = new RequestError[0];
35
36 public static final List<RequestError> EMPTY_LIST = Lists.newArrayList();
37
38 /**
39 * A code that uniquely identifies the error that occurred.
40 */
41 private final String code;
42
43 /**
44 * A short description of the error.
45 */
46 private final String message;
47
48 /**
49 * The stack trace associated with processing the request, used for debugging the server.
50 */
51 private final String stackTrace;
52
53 /**
54 * Constructor for {@link RequestError}.
55 */
56 public RequestError(String code, String message, String stackTrace) {
57 this.code = code;
58 this.message = message;
59 this.stackTrace = stackTrace;
60 }
61
62 @Override
63 public boolean equals(Object obj) {
64 if (obj instanceof RequestError) {
65 RequestError other = (RequestError) obj;
66 return
67 ObjectUtilities.equals(other.code, code) &&
68 ObjectUtilities.equals(other.message, message) &&
69 ObjectUtilities.equals(other.stackTrace, stackTrace);
70 }
71 return false;
72 }
73
74 public static RequestError fromJson(JsonObject jsonObject) {
75 String code = jsonObject.get("code").getAsString();
76 String message = jsonObject.get("message").getAsString();
77 String stackTrace = jsonObject.get("stackTrace") == null ? null : jsonObject.get("stackTrace").getAsString();
78 return new RequestError(code, message, stackTrace);
79 }
80
81 public static List<RequestError> fromJsonArray(JsonArray jsonArray) {
82 if (jsonArray == null) {
83 return EMPTY_LIST;
84 }
85 ArrayList<RequestError> list = new ArrayList<RequestError>(jsonArray.size());
86 Iterator<JsonElement> iterator = jsonArray.iterator();
87 while (iterator.hasNext()) {
88 list.add(fromJson(iterator.next().getAsJsonObject()));
89 }
90 return list;
91 }
92
93 /**
94 * A code that uniquely identifies the error that occurred.
95 */
96 public String getCode() {
97 return code;
98 }
99
100 /**
101 * A short description of the error.
102 */
103 public String getMessage() {
104 return message;
105 }
106
107 /**
108 * The stack trace associated with processing the request, used for debugging the server.
109 */
110 public String getStackTrace() {
111 return stackTrace;
112 }
113
114 @Override
115 public int hashCode() {
116 HashCodeBuilder builder = new HashCodeBuilder();
117 builder.append(code);
118 builder.append(message);
119 builder.append(stackTrace);
120 return builder.toHashCode();
121 }
122
123 public JsonObject toJson() {
124 JsonObject jsonObject = new JsonObject();
125 jsonObject.addProperty("code", code);
126 jsonObject.addProperty("message", message);
127 if (stackTrace != null) {
128 jsonObject.addProperty("stackTrace", stackTrace);
129 }
130 return jsonObject;
131 }
132
133 @Override
134 public String toString() {
135 StringBuilder builder = new StringBuilder();
136 builder.append("[");
137 builder.append("code=");
138 builder.append(code + ", ");
139 builder.append("message=");
140 builder.append(message + ", ");
141 builder.append("stackTrace=");
142 builder.append(stackTrace);
143 builder.append("]");
144 return builder.toString();
145 }
146
147}
static List< RequestError > fromJsonArray(JsonArray jsonArray)
RequestError(String code, String message, String stackTrace)
static RequestError fromJson(JsonObject jsonObject)
Win32Message message