/Users/deen/code/yugabyte-db/src/yb/client/error.h
Line | Count | Source |
1 | | // Copyright (c) YugaByte, Inc. |
2 | | // |
3 | | // Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except |
4 | | // in compliance with the License. You may obtain a copy of the License at |
5 | | // |
6 | | // http://www.apache.org/licenses/LICENSE-2.0 |
7 | | // |
8 | | // Unless required by applicable law or agreed to in writing, software distributed under the License |
9 | | // is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express |
10 | | // or implied. See the License for the specific language governing permissions and limitations |
11 | | // under the License. |
12 | | // |
13 | | |
14 | | #ifndef YB_CLIENT_ERROR_H |
15 | | #define YB_CLIENT_ERROR_H |
16 | | |
17 | | #include "yb/client/client_fwd.h" |
18 | | |
19 | | #include "yb/util/status.h" |
20 | | |
21 | | namespace yb { |
22 | | namespace client { |
23 | | |
24 | | // An error which occurred in a given operation. This tracks the operation |
25 | | // which caused the error, along with whatever the actual error was. |
26 | | class YBError { |
27 | | public: |
28 | | YBError(std::shared_ptr<YBOperation> failed_op, const Status& error); |
29 | | ~YBError(); |
30 | | |
31 | | // Return the actual error which occurred. |
32 | | const Status& status() const; |
33 | | |
34 | | // Return the operation which failed. |
35 | | const YBOperation& failed_op() const; |
36 | | YBOperation& failed_op(); |
37 | 9.03k | std::shared_ptr<YBOperation> shared_failed_op() const { return failed_op_; } |
38 | | |
39 | | // In some cases, it's possible that the server did receive and successfully |
40 | | // perform the requested operation, but the client can't tell whether or not |
41 | | // it was successful. For example, if the call times out, the server may still |
42 | | // succeed in processing at a later time. |
43 | | // |
44 | | // This function returns true if there is some chance that the server did |
45 | | // process the operation, and false if it can guarantee that the operation |
46 | | // did not succeed. |
47 | | bool was_possibly_successful() const; |
48 | | |
49 | | private: |
50 | | std::shared_ptr<YBOperation> failed_op_; |
51 | | Status status_; |
52 | | }; |
53 | | |
54 | | } // namespace client |
55 | | } // namespace yb |
56 | | |
57 | | #endif // YB_CLIENT_ERROR_H |