20862: Merge branch 'main' into 20862-google-api-client
[arvados.git] / sdk / ruby-google-api-client / lib / google / api_client / errors.rb
1 # Copyright 2010 Google Inc.
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
16 module Google
17   class APIClient
18     ##
19     # An error which is raised when there is an unexpected response or other
20     # transport error that prevents an operation from succeeding.
21     class TransmissionError < StandardError
22       attr_reader :result
23       def initialize(message = nil, result = nil)
24         super(message)
25         @result = result
26       end
27     end
28
29     ##
30     # An exception that is raised if a redirect is required
31     #
32     class RedirectError < TransmissionError
33     end
34
35     ##
36     # An exception that is raised if a method is called with missing or
37     # invalid parameter values.
38     class ValidationError < StandardError
39     end
40
41     ##
42     # A 4xx class HTTP error occurred.
43     class ClientError < TransmissionError
44     end
45
46     ##
47     # A 401 HTTP error occurred.
48     class AuthorizationError < ClientError
49     end
50
51     ##
52     # A 5xx class HTTP error occurred.
53     class ServerError < TransmissionError
54     end
55
56     ##
57     # An exception that is raised if an ID token could not be validated.
58     class InvalidIDTokenError < StandardError
59     end
60
61     # Error class for problems in batch requests.
62     class BatchError < StandardError
63     end
64   end
65 end