Google Cloud C++ Client
1.33.0
C++ Client Library for Google Cloud Platform
status.cc
Go to the documentation of this file.
1
// Copyright 2018 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
#
include
"google/cloud/status.h"
16
#
include
<
sstream
>
17
18
namespace
google
{
19
namespace
cloud
{
20
GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN
21
namespace
{
22
std::string StatusWhat(
Status
const
& status) {
23
std::ostringstream os;
24
os << status;
25
return
std::move(os).str();
26
}
27
}
// namespace
28
29
std::string
StatusCodeToString
(
StatusCode
code) {
30
switch
(code) {
31
case
StatusCode
::
kOk
:
32
return
"OK"
;
33
case
StatusCode
::
kCancelled
:
34
return
"CANCELLED"
;
35
case
StatusCode
::
kUnknown
:
36
return
"UNKNOWN"
;
37
case
StatusCode
::
kInvalidArgument
:
38
return
"INVALID_ARGUMENT"
;
39
case
StatusCode
::
kDeadlineExceeded
:
40
return
"DEADLINE_EXCEEDED"
;
41
case
StatusCode
::
kNotFound
:
42
return
"NOT_FOUND"
;
43
case
StatusCode
::
kAlreadyExists
:
44
return
"ALREADY_EXISTS"
;
45
case
StatusCode
::
kPermissionDenied
:
46
return
"PERMISSION_DENIED"
;
47
case
StatusCode
::
kUnauthenticated
:
48
return
"UNAUTHENTICATED"
;
49
case
StatusCode
::
kResourceExhausted
:
50
return
"RESOURCE_EXHAUSTED"
;
51
case
StatusCode
::
kFailedPrecondition
:
52
return
"FAILED_PRECONDITION"
;
53
case
StatusCode
::
kAborted
:
54
return
"ABORTED"
;
55
case
StatusCode
::
kOutOfRange
:
56
return
"OUT_OF_RANGE"
;
57
case
StatusCode
::
kUnimplemented
:
58
return
"UNIMPLEMENTED"
;
59
case
StatusCode
::
kInternal
:
60
return
"INTERNAL"
;
61
case
StatusCode
::
kUnavailable
:
62
return
"UNAVAILABLE"
;
63
case
StatusCode
::
kDataLoss
:
64
return
"DATA_LOSS"
;
65
default
:
66
return
"UNEXPECTED_STATUS_CODE="
+ std::to_string(
static_cast
<
int
>(code));
67
}
68
}
69
70
std::ostream& operator<<(std::ostream& os,
StatusCode
code) {
71
return
os <<
StatusCodeToString
(
code
)
;
72
}
73
74
RuntimeStatusError
::
RuntimeStatusError
(
Status
status)
75
: std::runtime_error(StatusWhat(status)), status_(std::move(status)) {}
76
77
GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END
78
}
// namespace cloud
79
}
// namespace google
Generated on Mon Nov 1 2021 19:48:14 for Google Cloud C++ Client by
1.9.1