-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: rewrap certain grpc errors (#810)
- Loading branch information
1 parent
c464fc5
commit 9842f9c
Showing
9 changed files
with
178 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# Copyright 2019 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. | ||
|
||
require "googleauth" | ||
require "gapic/common/error" | ||
|
||
module Gapic | ||
module GRPC | ||
## | ||
# An error class to represent the Authorization Error. | ||
# The GRPC layer wraps auth plugin errors in ::GRPC::Unavailable. | ||
# This class rewraps those GRPC layer errors, presenting a correct status code. | ||
# | ||
class AuthorizationError < ::GRPC::Unauthenticated | ||
end | ||
|
||
## | ||
# An error class that represents Deadline Exceeded error with an optional | ||
# retry root cause. | ||
# | ||
# The GRPC layer throws ::GRPC::DeadlineExceeded without any context. | ||
# If the deadline was exceeded while retrying another exception (e.g. | ||
# ::GRPC::Unavailable), that exception could be useful for understanding | ||
# the readon for the timeout. | ||
# | ||
# This exception rewraps ::GRPC::DeadlineExceeded, adding an exception | ||
# that was being retried until the deadline was exceeded (if any) as a | ||
# `root_cause` attribute. | ||
# | ||
# @!attribute [r] root_cause | ||
# @return [Object, nil] The exception that was being retried | ||
# when the DeadlineExceeded error occured. | ||
# | ||
class DeadlineExceededError < ::GRPC::DeadlineExceeded | ||
attr_reader :root_cause | ||
|
||
## | ||
# @param message [String] The error message. | ||
# | ||
# @param root_cause [Object, nil] The exception that was being retried | ||
# when the DeadlineExceeded error occured. | ||
# | ||
def initialize message, root_cause: nil | ||
super message | ||
@root_cause = root_cause | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters