mirror of https://github.com/grpc/grpc.git
[AbortError] Reapply "[AbortError] And and check AbortError while abort" (#34525)
Reverts grpc/grpc#34515
This PR reapplies AbortError change as the previous one was reverted.
This change was mentioned in this gRFC: [L105: Python Add New Error Types](https://github.com/grpc/proposal/blob/master/L105-python-expose-new-error-types.md)
Closes #34525
COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/34525 from grpc:revert-34515-revert-33969-checkAbortError ce63ab1d6a
PiperOrigin-RevId: 613718295
pull/36076/head
parent
d1cea2dd09
commit
675dcccd5e
18 changed files with 139 additions and 49 deletions
@ -0,0 +1,57 @@ |
|||||||
|
# Copyright 2024 The gRPC authors. |
||||||
|
# |
||||||
|
# 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 |
||||||
|
# |
||||||
|
# http://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. |
||||||
|
|
||||||
|
############################# gRPC Exceptions ################################ |
||||||
|
|
||||||
|
|
||||||
|
class BaseError(Exception): |
||||||
|
""" |
||||||
|
The base class for exceptions generated by gRPC. |
||||||
|
""" |
||||||
|
|
||||||
|
|
||||||
|
class UsageError(BaseError): |
||||||
|
""" |
||||||
|
Raised when the usage of API by applications is inappropriate. |
||||||
|
For example, trying to invoke RPC on a closed channel, mixing two styles |
||||||
|
of streaming API on the client side. This exception should not be |
||||||
|
suppressed. |
||||||
|
""" |
||||||
|
|
||||||
|
|
||||||
|
class AbortError(BaseError): |
||||||
|
""" |
||||||
|
Raised when calling abort in servicer methods. |
||||||
|
This exception should not be suppressed. Applications may catch it to |
||||||
|
perform certain clean-up logic, and then re-raise it. |
||||||
|
""" |
||||||
|
|
||||||
|
|
||||||
|
class InternalError(BaseError): |
||||||
|
""" |
||||||
|
Raised upon unexpected errors in native code. |
||||||
|
""" |
||||||
|
|
||||||
|
|
||||||
|
class RpcError(BaseError): |
||||||
|
"""Raised by the gRPC library to indicate non-OK-status RPC termination.""" |
||||||
|
|
||||||
|
|
||||||
|
__all__ = ( |
||||||
|
"BaseError", |
||||||
|
"UsageError", |
||||||
|
"AbortError", |
||||||
|
"InternalError", |
||||||
|
"RpcError", |
||||||
|
) |
Loading…
Reference in new issue