Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
Grpc
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
tci-gateway-module
Grpc
Commits
e7209c58
Commit
e7209c58
authored
Sep 3, 2015
by
Jorge Canizales
Browse files
Options
Downloads
Patches
Plain Diff
Propagate parsing error if we get a bad response
parent
ddb58ea5
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/objective-c/ProtoRPC/ProtoRPC.m
+14
-3
14 additions, 3 deletions
src/objective-c/ProtoRPC/ProtoRPC.m
with
14 additions
and
3 deletions
src/objective-c/ProtoRPC/ProtoRPC.m
+
14
−
3
View file @
e7209c58
...
@@ -65,14 +65,25 @@
...
@@ -65,14 +65,25 @@
}
}
// A writer that serializes the proto messages to send.
// A writer that serializes the proto messages to send.
GRXWriter
*
bytesWriter
=
[
requestsWriter
map
:
^
id
(
GPBMessage
*
proto
)
{
GRXWriter
*
bytesWriter
=
[
requestsWriter
map
:
^
id
(
GPBMessage
*
proto
)
{
// TODO(jcanizales): Fail with an understandable error message if the requestsWriter isn't
if
(
!
[
proto
isKindOfClass
:
GPBMessage
.
class
])
{
// sending GPBMessages.
[
NSException
raise
:
NSInvalidArgumentException
format:
@"Request must be a proto message: %@"
,
proto
];
}
return
[
proto
data
];
return
[
proto
data
];
}];
}];
if
((
self
=
[
super
initWithHost
:
host
path
:
method
.
HTTPPath
requestsWriter
:
bytesWriter
]))
{
if
((
self
=
[
super
initWithHost
:
host
path
:
method
.
HTTPPath
requestsWriter
:
bytesWriter
]))
{
__weak
ProtoRPC
*
weakSelf
=
self
;
// A writeable that parses the proto messages received.
// A writeable that parses the proto messages received.
_responseWriteable
=
[[
GRXWriteable
alloc
]
initWithValueHandler
:
^
(
NSData
*
value
)
{
_responseWriteable
=
[[
GRXWriteable
alloc
]
initWithValueHandler
:
^
(
NSData
*
value
)
{
[
responsesWriteable
writeValue
:[
responseClass
parseFromData
:
value
error
:
NULL
]];
// TODO(jcanizales): This is done in the main thread, and needs to happen in another thread.
NSError
*
error
=
nil
;
id
parsed
=
[
responseClass
parseFromData
:
value
error
:
&
error
];
if
(
parsed
)
{
[
responsesWriteable
writeValue
:
parsed
];
}
else
{
[
weakSelf
finishWithError
:
error
];
}
}
completionHandler
:
^
(
NSError
*
errorOrNil
)
{
}
completionHandler
:
^
(
NSError
*
errorOrNil
)
{
[
responsesWriteable
writesFinishedWithError
:
errorOrNil
];
[
responsesWriteable
writesFinishedWithError
:
errorOrNil
];
}];
}];
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
sign in
to comment