1 /*
2  * Copyright (c) Facebook, Inc. and its affiliates.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #pragma once
18 
19 #include <folly/Range.h>
20 
21 namespace apache {
22 namespace thrift {
23 namespace rocket {
24 
25 enum class ErrorCode : uint32_t {
26   // Reserved
27   RESERVED = 0x00000000,
28   // The Setup frame is invalid for the server (it could be that the client is
29   // too recent for the old server). Stream ID MUST be 0.
30   INVALID_SETUP = 0x00000001,
31   // Some (or all) of the parameters specified by the client are unsupported by
32   // the server. Stream ID MUST be 0.
33   UNSUPPORTED_SETUP = 0x00000002,
34   // The server rejected the setup, it can specify the reason in the payload.
35   // Stream ID MUST be 0.
36   REJECTED_SETUP = 0x00000003,
37   // The server rejected the resume, it can specify the reason in the payload.
38   // Stream ID MUST be 0.
39   REJECTED_RESUME = 0x00000004,
40   // The connection is being terminated. Stream ID MUST be 0. Sender or Receiver
41   // of this frame MAY close the connection immediately without waiting for
42   // outstanding streams to terminate.
43   CONNECTION_ERROR = 0x00000101,
44   //  The connection is being terminated. Stream ID MUST be 0. Sender or
45   //  Receiver of this frame MUST wait for outstanding streams to terminate
46   //  before closing the connection. New requests MAY not be accepted.
47   CONNECTION_CLOSE = 0x00000102,
48   // Application layer logic generating a Reactive Streams onError event. Stream
49   // ID MUST be > 0.
50   APPLICATION_ERROR = 0x00000201,
51   // Despite being a valid request, the Responder decided to reject it. The
52   // Responder guarantees that it didn't process the request. The reason for the
53   // rejection is explained in the Error Data section. Stream ID MUST be > 0.
54   REJECTED = 0x00000202,
55   // The Responder canceled the request but may have started processing it
56   // (similar to REJECTED but doesn't guarantee lack of side-effects). Stream ID
57   // MUST be > 0.
58   CANCELED = 0x00000203,
59   // The request is invalid. Stream ID MUST be > 0.
60   INVALID = 0x00000204,
61   // The connection is being terminated. Stream ID MUST be 0. Sender of this
62   // frame MUST not send any other frames after this frame. Sender guarantees
63   // that if it hasn't responded to a request before sending this frame, then
64   // it didn't process that request.
65   CONNECTION_DRAIN_COMPLETE = 0xFB000000,
66   // The connection is closed because of exceeding ingress memory limit.
67   EXCEEDED_INGRESS_MEM_LIMIT = 0xFB000001,
68   // Reserved for extension use.
69   RESERVED_EXT = 0xFFFFFFFF,
70 };
71 
72 folly::StringPiece toString(ErrorCode ec);
73 
74 } // namespace rocket
75 } // namespace thrift
76 } // namespace apache
77