mirror of https://github.com/grpc/grpc.git
[AbortError] And and check AbortError while abort (#33969)
Fix: https://github.com/grpc/grpc/issues/33890 In case of abort, currently we don't log anything, this change added an `AbortError` as the default error for abort, if any other error happened, we'll log the error so user will be aware of the other error. Related gRFC: https://github.com/grpc/proposal/pull/388 ### Testing * Tested locally, after this change, any non-AbortError will be logged, sample log: ``` ERROR:grpc._server:Exception happened while abort: Other exception happened! Traceback (most recent call last): File "/usr/local/google/home/xuanwn/.cache/bazel/_bazel_xuanwn/da3828576aa39e99a5c826cc2e2e22fb/sandbox/linux-sandbox/9/execroot/com_github_grpc_grpc/bazel-out/k8-fastbuild/bin/src/python/grpcio_tests/tests/unit/_abort_test.native.runfiles/com_github_grpc_grpc/src/python/grpcio/grpc/_server.py", line 553, in _call_behavior response_or_iterator = behavior(argument, context) File "/usr/local/google/home/xuanwn/.cache/bazel/_bazel_xuanwn/da3828576aa39e99a5c826cc2e2e22fb/sandbox/linux-sandbox/9/execroot/com_github_grpc_grpc/bazel-out/k8-fastbuild/bin/src/python/grpcio_tests/tests/unit/_abort_test.native.runfiles/com_github_grpc_grpc/src/python/grpcio_tests/tests/unit/_abort_test.py", line 95, in abort_with_status_unary_unary_raise_additional_exception raise Exception("Other exception happened!") Exception: Other exception happened! ```pull/34509/head
parent
835775e347
commit
b807a195fd
6 changed files with 59 additions and 26 deletions
@ -0,0 +1,40 @@ |
||||
# Copyright 2023 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. |
||||
|
||||
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. |
||||
""" |
Loading…
Reference in new issue