/Users/deen/code/yugabyte-db/src/yb/client/error_collector.cc
Line | Count | Source |
1 | | // Licensed to the Apache Software Foundation (ASF) under one |
2 | | // or more contributor license agreements. See the NOTICE file |
3 | | // distributed with this work for additional information |
4 | | // regarding copyright ownership. The ASF licenses this file |
5 | | // to you under the Apache License, Version 2.0 (the |
6 | | // "License"); you may not use this file except in compliance |
7 | | // with the License. You may obtain a copy of the License at |
8 | | // |
9 | | // http://www.apache.org/licenses/LICENSE-2.0 |
10 | | // |
11 | | // Unless required by applicable law or agreed to in writing, |
12 | | // software distributed under the License is distributed on an |
13 | | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
14 | | // KIND, either express or implied. See the License for the |
15 | | // specific language governing permissions and limitations |
16 | | // under the License. |
17 | | // |
18 | | // The following only applies to changes made to this file as part of YugaByte development. |
19 | | // |
20 | | // Portions Copyright (c) YugaByte, Inc. |
21 | | // |
22 | | // Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except |
23 | | // in compliance with the License. You may obtain a copy of the License at |
24 | | // |
25 | | // http://www.apache.org/licenses/LICENSE-2.0 |
26 | | // |
27 | | // Unless required by applicable law or agreed to in writing, software distributed under the License |
28 | | // is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express |
29 | | // or implied. See the License for the specific language governing permissions and limitations |
30 | | // under the License. |
31 | | // |
32 | | |
33 | | #include "yb/client/error_collector.h" |
34 | | |
35 | | #include "yb/client/error.h" |
36 | | #include "yb/client/yb_op.h" |
37 | | |
38 | | namespace yb { |
39 | | namespace client { |
40 | | namespace internal { |
41 | | |
42 | 5.74M | ErrorCollector::ErrorCollector() { |
43 | 5.74M | } |
44 | | |
45 | 5.76M | ErrorCollector::~ErrorCollector() {} |
46 | | |
47 | 496k | void ErrorCollector::AddError(std::unique_ptr<YBError> error) { |
48 | 18.4E | LOG_IF(DFATAL, error->status().ok()) |
49 | 18.4E | << "Unexpected to add OK status as error for: " << error->failed_op().ToString(); |
50 | 496k | errors_.push_back(std::move(error)); |
51 | 496k | } |
52 | | |
53 | 5.75M | size_t ErrorCollector::CountErrors() const { |
54 | 5.75M | return errors_.size(); |
55 | 5.75M | } |
56 | | |
57 | 5.74M | CollectedErrors ErrorCollector::GetAndClearErrors() { |
58 | 5.74M | CollectedErrors result; |
59 | 5.74M | errors_.swap(result); |
60 | 5.74M | return result; |
61 | 5.74M | } |
62 | | |
63 | 496k | void ErrorCollector::AddError(std::shared_ptr<YBOperation> operation, Status status) { |
64 | 496k | AddError(std::make_unique<YBError>(std::move(operation), std::move(status))); |
65 | 496k | } |
66 | | |
67 | | } // namespace internal |
68 | | } // namespace client |
69 | | } // namespace yb |