1 // Copyright (C) 2019 Google LLC 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 #ifndef ICING_ABSL_PORTS_CANONICAL_ERRORS_H_ 16 #define ICING_ABSL_PORTS_CANONICAL_ERRORS_H_ 17 18 #include <string_view> 19 20 #include "icing/text_classifier/lib3/utils/base/status.h" 21 22 namespace icing { 23 namespace lib { 24 namespace absl_ports { 25 26 libtextclassifier3::Status CancelledError(std::string_view error_message); 27 libtextclassifier3::Status UnknownError(std::string_view error_message); 28 libtextclassifier3::Status InvalidArgumentError(std::string_view error_message); 29 libtextclassifier3::Status DeadlineExceededError( 30 std::string_view error_message); 31 libtextclassifier3::Status NotFoundError(std::string_view error_message); 32 libtextclassifier3::Status AlreadyExistsError(std::string_view error_message); 33 libtextclassifier3::Status PermissionDeniedError( 34 std::string_view error_message); 35 libtextclassifier3::Status ResourceExhaustedError( 36 std::string_view error_message); 37 libtextclassifier3::Status FailedPreconditionError( 38 std::string_view error_message); 39 libtextclassifier3::Status AbortedError(std::string_view error_message); 40 libtextclassifier3::Status OutOfRangeError(std::string_view error_message); 41 libtextclassifier3::Status UnimplementedError(std::string_view error_message); 42 libtextclassifier3::Status InternalError(std::string_view error_message); 43 libtextclassifier3::Status UnavailableError(std::string_view error_message); 44 libtextclassifier3::Status DataLossError(std::string_view error_message); 45 libtextclassifier3::Status UnauthenticatedError(std::string_view error_message); 46 47 bool IsCancelled(const libtextclassifier3::Status& status); 48 bool IsUnknown(const libtextclassifier3::Status& status); 49 bool IsInvalidArgument(const libtextclassifier3::Status& status); 50 bool IsDeadlineExceeded(const libtextclassifier3::Status& status); 51 bool IsNotFound(const libtextclassifier3::Status& status); 52 bool IsAlreadyExists(const libtextclassifier3::Status& status); 53 bool IsPermissionDenied(const libtextclassifier3::Status& status); 54 bool IsResourceExhausted(const libtextclassifier3::Status& status); 55 bool IsFailedPrecondition(const libtextclassifier3::Status& status); 56 bool IsAborted(const libtextclassifier3::Status& status); 57 bool IsOutOfRange(const libtextclassifier3::Status& status); 58 bool IsUnimplemented(const libtextclassifier3::Status& status); 59 bool IsInternal(const libtextclassifier3::Status& status); 60 bool IsUnavailable(const libtextclassifier3::Status& status); 61 bool IsDataLoss(const libtextclassifier3::Status& status); 62 bool IsUnauthenticated(const libtextclassifier3::Status& status); 63 64 } // namespace absl_ports 65 } // namespace lib 66 } // namespace icing 67 68 #endif // ICING_ABSL_PORTS_CANONICAL_ERRORS_H_ 69