1 /* Copyright 2020 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 #include "tensorflow_lite_support/cc/common.h"
17 
18 #include "absl/strings/cord.h"
19 #include "absl/strings/str_cat.h"
20 
21 namespace tflite {
22 namespace support {
23 
CreateStatusWithPayload(absl::StatusCode canonical_code,absl::string_view message,TfLiteSupportStatus tfls_code)24 absl::Status CreateStatusWithPayload(absl::StatusCode canonical_code,
25                                      absl::string_view message,
26                                      TfLiteSupportStatus tfls_code) {
27   // NOTE: Ignores `message` if the canonical code is ok.
28   absl::Status status = absl::Status(canonical_code, message);
29   // NOTE: Does nothing if the canonical code is ok.
30   status.SetPayload(kTfLiteSupportPayload, absl::Cord(absl::StrCat(tfls_code)));
31   return status;
32 }
33 
34 }  // namespace support
35 }  // namespace tflite
36