xref: /aosp_15_r20/external/tensorflow/tensorflow/core/platform/error_payloads.h (revision b6fb3261f9314811a0f4371741dbb8839866f948)
1 /* Copyright 2022 The TensorFlow Authors. All Rights Reserved.
2 
3 Licensed under the Apache License, Version 2.0 (the "License");
4 you may not use this file except in compliance with the License.
5 You may obtain a copy of the License at
6 
7     http://www.apache.org/licenses/LICENSE-2.0
8 
9 Unless required by applicable law or agreed to in writing, software
10 distributed under the License is distributed on an "AS IS" BASIS,
11 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 See the License for the specific language governing permissions and
13 limitations under the License.
14 ==============================================================================*/
15 
16 #ifndef TENSORFLOW_CORE_PLATFORM_ERROR_PAYLOADS_H_
17 #define TENSORFLOW_CORE_PLATFORM_ERROR_PAYLOADS_H_
18 
19 #include "tensorflow/core/lib/core/status.h"
20 #include "tensorflow/core/protobuf/core_platform_payloads.pb.h"
21 // This file contains macros and payload keys for the error counter in
22 // EagerClient.
23 
24 namespace tensorflow {
25 
26 // Proto: tensorflow::core::platform::ErrorSourceProto
27 // Location: tensorflow/core/protobuf/core_platform_payloads.proto
28 // Usage: Payload key for recording the error raised source. Payload value is
29 // retrieved to update counter in
30 // tensorflow/core/distributed_runtime/rpc/eager/grpc_eager_client.cc.
31 constexpr char kErrorSource[] =
32     "type.googleapis.com/tensorflow.core.platform.ErrorSourceProto";
33 
34 // Set payload when status is not ok and ErrorSource payload hasn't been set.
35 // The code below will be used at every place where we would like to catch
36 // the error for the error counter in EagerClient.
37 
38 void OkOrSetErrorCounterPayload(
39     const tensorflow::core::platform::ErrorSourceProto::ErrorSource&
40         error_source,
41     tensorflow::Status& status);
42 }  // namespace tensorflow
43 
44 #endif  // TENSORFLOW_CORE_PLATFORM_ERROR_PAYLOADS_H_
45