Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
B
brpc
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
brpc
Commits
ec5c3681
Commit
ec5c3681
authored
Sep 27, 2018
by
zhujiashun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a case in ErrorCodeToGrpcStatus
parent
2e471c02
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
8 deletions
+10
-8
grpc.cpp
src/brpc/grpc.cpp
+3
-1
brpc_grpc_protocol_unittest.cpp
test/brpc_grpc_protocol_unittest.cpp
+7
-7
No files found.
src/brpc/grpc.cpp
View file @
ec5c3681
...
...
@@ -26,6 +26,8 @@ namespace brpc {
GrpcStatus
ErrorCodeToGrpcStatus
(
int
error_code
)
{
switch
(
error_code
)
{
case
0
:
return
GRPC_OK
;
case
ENOSERVICE
:
case
ENOMETHOD
:
return
GRPC_UNIMPLEMENTED
;
...
...
@@ -43,7 +45,7 @@ GrpcStatus ErrorCodeToGrpcStatus(int error_code) {
case
ETIMEDOUT
:
return
GRPC_INTERNAL
;
default
:
return
GRPC_
OK
;
return
GRPC_
INTERNAL
;
}
}
...
...
test/brpc_grpc_protocol_unittest.cpp
View file @
ec5c3681
...
...
@@ -63,6 +63,7 @@ public:
if
(
req
->
has_error_code
())
{
const
std
::
string
err_msg
=
butil
::
string_printf
(
"%s%d"
,
g_prefix
.
c_str
(),
req
->
error_code
());
// TODO(zhujiashun): set and check error_code when GrpcStatusToErrorCode is done
cntl
->
SetFailed
(
err_msg
.
c_str
());
return
;
}
...
...
@@ -109,7 +110,6 @@ protected:
stub
.
Method
(
&
cntl
,
&
req
,
&
res
,
NULL
);
EXPECT_FALSE
(
cntl
.
Failed
())
<<
cntl
.
ErrorCode
()
<<
": "
<<
cntl
.
ErrorText
();
EXPECT_EQ
(
res
.
message
(),
g_prefix
+
g_req
);
//EXPECT_EQ(brpc::GRPC_OK, cntl.grpc_status());
}
brpc
::
Server
_server
;
...
...
@@ -164,9 +164,9 @@ TEST_F(GrpcTest, return_error) {
test
::
GrpcService_Stub
stub
(
&
_channel
);
stub
.
Method
(
&
cntl
,
&
req
,
&
res
,
NULL
);
EXPECT_TRUE
(
cntl
.
Failed
());
//
FIXME(zhujiashun): message body is empty so the Errorcode may be ERESPONSE
//
EXPECT_EQ(cntl.ErrorCode(), brpc::EINTERNAL);
// EXPECT_EQ(cntl.ErrorText(), butil::string_printf("%s%d", g_prefix.c_str(), i
));
//
TODO(zhujiashun): set and check error_code when GrpcStatusToErrorCode is done
EXPECT_EQ
(
cntl
.
ErrorCode
(),
brpc
::
EINTERNAL
);
EXPECT_TRUE
(
butil
::
StringPiece
(
cntl
.
ErrorText
()).
ends_with
(
butil
::
string_printf
(
"%s%d"
,
g_prefix
.
c_str
(),
i
)
));
}
}
...
...
@@ -195,9 +195,9 @@ TEST_F(GrpcTest, MethodNotExist) {
test
::
GrpcService_Stub
stub
(
&
_channel
);
stub
.
MethodNotExist
(
&
cntl
,
&
req
,
&
res
,
NULL
);
EXPECT_TRUE
(
cntl
.
Failed
());
//
FIXME(zhujiashun): message body is empty so the Errorcode may be ERESPONSE
//
EXPECT_EQ(cntl.ErrorCode(), brpc::EINTERNAL);
//
ASSERT_TRUE(butil::StringPiece(cntl.ErrorText()).ends_with("Method MethodNotExist() not implemented."));
//
TODO(zhujiashun): set and check error_code when GrpcStatusToErrorCode is done
EXPECT_EQ
(
cntl
.
ErrorCode
(),
brpc
::
EINTERNAL
);
ASSERT_TRUE
(
butil
::
StringPiece
(
cntl
.
ErrorText
()).
ends_with
(
"Method MethodNotExist() not implemented."
));
}
}
// namespace
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment