Flutter Engine
The Flutter Engine
third_party
dart-lang
sdk
pkg
vm_service
java
src
org
dartlang
vm
service
internal
ErrorRequestSink.java
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2015, the Dart project authors.
3
*
4
* Licensed under the Eclipse Public License v1.0 (the "License"); you may not use this file except
5
* in compliance with the License. You may obtain a copy of the License at
6
*
7
* http://www.eclipse.org/legal/epl-v10.html
8
*
9
* Unless required by applicable law or agreed to in writing, software distributed under the License
10
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11
* or implied. See the License for the specific language governing permissions and limitations under
12
* the License.
13
*/
14
package
org.dartlang.vm.service.internal;
15
16
import
com.google.gson.JsonObject;
17
import
org.dartlang.vm.service.logging.Logging;
18
19
/**
20
* A {@link RequestSink} that reports with an error to each request.
21
*/
22
public
class
ErrorRequestSink
implements
RequestSink
,
VmServiceConst
{
23
/**
24
* The {@link ResponseSink} to send error responses to.
25
*/
26
private
final
ResponseSink
responseSink;
27
28
private
final
String code;
29
private
final
String message;
30
31
public
ErrorRequestSink
(
ResponseSink
responseSink, String code, String message) {
32
if
(responseSink ==
null
|| code ==
null
||
message
==
null
) {
33
throw
new
IllegalArgumentException(
"Unexpected null argument: "
+ responseSink +
" "
34
+ code +
" "
+
message
);
35
}
36
this.responseSink = responseSink;
37
this.code = code;
38
this.message =
message
;
39
}
40
41
@Override
42
public
void
add
(JsonObject request) {
43
String
id
= request.getAsJsonPrimitive(
ID
).getAsString();
44
try
{
45
// TODO(danrubel) is this the correct format for an error response?
46
JsonObject
error
=
new
JsonObject();
47
error
.addProperty(
CODE
, code);
48
error
.addProperty(
MESSAGE
,
message
);
49
JsonObject response =
new
JsonObject();
50
response.addProperty(
ID
,
id
);
51
response.add(
ERROR
,
error
);
52
responseSink.
add
(response);
53
}
catch
(Throwable
e
) {
54
Logging
.
getLogger
().
logError
(
e
.getMessage(),
e
);
55
}
56
}
57
58
@Override
59
public
void
close
() {
60
}
61
}
org.dartlang.vm.service.internal.ErrorRequestSink
Definition:
ErrorRequestSink.java:22
org.dartlang.vm.service.internal.ErrorRequestSink.close
void close()
Definition:
ErrorRequestSink.java:59
org.dartlang.vm.service.internal.ErrorRequestSink.ErrorRequestSink
ErrorRequestSink(ResponseSink responseSink, String code, String message)
Definition:
ErrorRequestSink.java:31
org.dartlang.vm.service.internal.ErrorRequestSink.add
void add(JsonObject request)
Definition:
ErrorRequestSink.java:42
org.dartlang.vm.service.logging.Logging
Definition:
Logging.java:19
org.dartlang.vm.service.logging.Logging.getLogger
static Logger getLogger()
Definition:
Logging.java:23
error
const uint8_t uint32_t uint32_t GError ** error
Definition:
fl_pixel_buffer_texture_test.cc:40
org.dartlang.vm.service.internal.RequestSink
Definition:
RequestSink.java:21
org.dartlang.vm.service.internal.ResponseSink
Definition:
ResponseSink.java:21
org.dartlang.vm.service.internal.ResponseSink.add
void add(JsonObject response)
org.dartlang.vm.service.internal.VmServiceConst
Definition:
VmServiceConst.java:19
org.dartlang.vm.service.internal.VmServiceConst.ID
static final String ID
Definition:
VmServiceConst.java:23
org.dartlang.vm.service.internal.VmServiceConst.CODE
static final String CODE
Definition:
VmServiceConst.java:20
org.dartlang.vm.service.internal.VmServiceConst.MESSAGE
static final String MESSAGE
Definition:
VmServiceConst.java:24
org.dartlang.vm.service.internal.VmServiceConst.ERROR
static final String ERROR
Definition:
VmServiceConst.java:21
org.dartlang.vm.service.logging.Logger.logError
void logError(String message)
message
Win32Message message
Definition:
keyboard_unittests.cc:139
protoc_wrapper.e
e
Definition:
protoc_wrapper.py:226
Generated on Sun Jun 23 2024 21:55:22 for Flutter Engine by
1.9.4