Permalink
Browse files

Apply try/catch block to specific section

So we don't catch from inside the delegate callback.
  • Loading branch information...
mxcl committed Oct 8, 2012
1 parent cca13ac commit 8b27b4c81290718633c6fadc4f45659aef068863
Showing with 5 additions and 4 deletions.
  1. +5 −4 MBWebSocketServer.m
View
@@ -94,13 +94,14 @@ - (void)onSocket:(AsyncSocket *)connection didReadData:(NSData *)data withTag:(l
[self respondToHandshake:data client:connection];
} else {
@try {
- [_delegate webSocketServer:self didReceiveData:[NSData dataWithWebSocketFrameData:data] fromConnection:connection];
- [connection readDataWithTimeout:-1 tag:3];
- }
- @catch (NSString *msg) {
+ data = [NSData dataWithWebSocketFrameData:data];
+ } @catch (NSString *msg) {
id error = [NSError errorWithDomain:@"com.methylblue" code:1 userInfo:@{NSLocalizedDescriptionKey: msg}];
[_delegate webSocketServer:self couldNotParseRawData:data fromConnection:connection error:error];
+ return;
}
+ [_delegate webSocketServer:self didReceiveData:data fromConnection:connection];
+ [connection readDataWithTimeout:-1 tag:3];
}
}

0 comments on commit 8b27b4c

Please sign in to comment.