-
Notifications
You must be signed in to change notification settings - Fork 73
Expand file tree
/
Copy patherrors.h
More file actions
93 lines (70 loc) · 3.9 KB
/
Copy patherrors.h
File metadata and controls
93 lines (70 loc) · 3.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
// Copyright 2022 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef THIRD_PARTY_CEL_CPP_EVAL_INTERNAL_ERRORS_H_
#define THIRD_PARTY_CEL_CPP_EVAL_INTERNAL_ERRORS_H_
#include "google/protobuf/arena.h"
#include "absl/status/status.h"
#include "base/memory.h"
namespace cel::interop_internal {
constexpr absl::string_view kErrNoMatchingOverload =
"No matching overloads found";
constexpr absl::string_view kErrNoSuchField = "no_such_field";
constexpr absl::string_view kErrNoSuchKey = "Key not found in map";
// Error name for MissingAttributeError indicating that evaluation has
// accessed an attribute whose value is undefined. go/terminal-unknown
constexpr absl::string_view kErrMissingAttribute = "MissingAttributeError: ";
constexpr absl::string_view kPayloadUrlMissingAttributePath =
"missing_attribute_path";
constexpr absl::string_view kPayloadUrlUnknownFunctionResult =
"cel_is_unknown_function_result";
const absl::Status* DurationOverflowError();
// Exclusive bounds for valid duration values.
constexpr absl::Duration kDurationHigh = absl::Seconds(315576000001);
constexpr absl::Duration kDurationLow = absl::Seconds(-315576000001);
// Factories for absl::Status values for well-known CEL errors.
// const pointer Results are arena allocated to support interop with cel::Handle
// and expr::runtime::CelValue.
// Memory manager implementation is assumed to be google::protobuf::Arena.
absl::Status CreateNoMatchingOverloadError(absl::string_view fn);
const absl::Status* CreateNoMatchingOverloadError(cel::MemoryManager& manager,
absl::string_view fn);
const absl::Status* CreateNoMatchingOverloadError(google::protobuf::Arena* arena,
absl::string_view fn);
const absl::Status* CreateNoSuchFieldError(cel::MemoryManager& manager,
absl::string_view field);
const absl::Status* CreateNoSuchFieldError(google::protobuf::Arena* arena,
absl::string_view field);
absl::Status CreateNoSuchFieldError(absl::string_view field);
const absl::Status* CreateNoSuchKeyError(cel::MemoryManager& manager,
absl::string_view key);
const absl::Status* CreateNoSuchKeyError(google::protobuf::Arena* arena,
absl::string_view key);
const absl::Status* CreateUnknownValueError(google::protobuf::Arena* arena,
absl::string_view unknown_path);
const absl::Status* CreateMissingAttributeError(
google::protobuf::Arena* arena, absl::string_view missing_attribute_path);
const absl::Status* CreateMissingAttributeError(
cel::MemoryManager& manager, absl::string_view missing_attribute_path);
const absl::Status* CreateUnknownFunctionResultError(
cel::MemoryManager& manager, absl::string_view help_message);
const absl::Status* CreateUnknownFunctionResultError(
google::protobuf::Arena* arena, absl::string_view help_message);
const absl::Status* CreateError(
google::protobuf::Arena* arena, absl::string_view message,
absl::StatusCode code = absl::StatusCode::kUnknown);
const absl::Status* CreateError(
cel::MemoryManager& manager, absl::string_view message,
absl::StatusCode code = absl::StatusCode::kUnknown);
} // namespace cel::interop_internal
#endif // THIRD_PARTY_CEL_CPP_EVAL_INTERNAL_ERRORS_H_