summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMuller, Alexander (A.) <amulle19@ford.com>2017-01-19 11:41:53 -0800
committerMuller, Alexander (A.) <amulle19@ford.com>2017-01-19 11:41:53 -0800
commit6d085f3d5a25ca5d774b56ff9262855983cb9215 (patch)
tree99f32be29198826e5917da0ffdd723cc3ba56ba9
parent1c280c1c21998f4781fca445a034e3d6c7e443ad (diff)
downloadsdl_ios-6d085f3d5a25ca5d774b56ff9262855983cb9215.tar.gz
Added a ParameterAssert instead of throwing an exception, along with returning a handler with an error.
-rw-r--r--SmartDeviceLink/SDLLifecycleManager.m10
-rw-r--r--SmartDeviceLinkTests/DevAPISpecs/SDLLifecycleManagerSpec.m2
2 files changed, 7 insertions, 5 deletions
diff --git a/SmartDeviceLink/SDLLifecycleManager.m b/SmartDeviceLink/SDLLifecycleManager.m
index 6b08bdd28..19d9717d6 100644
--- a/SmartDeviceLink/SDLLifecycleManager.m
+++ b/SmartDeviceLink/SDLLifecycleManager.m
@@ -367,12 +367,14 @@ SDLLifecycleState *const SDLLifecycleStateReady = @"Ready";
- (void)sdl_sendRequest:(SDLRPCRequest *)request withResponseHandler:(nullable SDLResponseHandler)handler {
// We will allow things to be sent in a "SDLLifeCycleStateTransportConnected" state in the private method, but block it in the public method sendRequest:withCompletionHandler: so that the lifecycle manager can complete its setup without being bothered by developer error
+ NSParameterAssert(request != nil);
+
// If, for some reason, the request is nil we should error out.
if (!request) {
- @throw [NSException
- exceptionWithName:NSInvalidArgumentException
- reason:@"A Request cannot be nil."
- userInfo:nil];
+ if (handler) {
+ handler(nil, nil, [NSError sdl_lifecycle_rpcErrorWithDescription:@"Nil Request Sent" andReason:@"A nil RPC request was passed and cannot be sent."]);
+ }
+ return;
}
// Add a correlation ID to the request
diff --git a/SmartDeviceLinkTests/DevAPISpecs/SDLLifecycleManagerSpec.m b/SmartDeviceLinkTests/DevAPISpecs/SDLLifecycleManagerSpec.m
index d98c6269e..91320c955 100644
--- a/SmartDeviceLinkTests/DevAPISpecs/SDLLifecycleManagerSpec.m
+++ b/SmartDeviceLinkTests/DevAPISpecs/SDLLifecycleManagerSpec.m
@@ -268,7 +268,7 @@ describe(@"a lifecycle manager", ^{
it(@"cannot send a nil RPC", ^{
SDLShow *testShow = nil;
- expectAction(^{ [testManager sendRequest:testShow]; }).to(raiseException().named(NSInvalidArgumentException));
+ expectAction(^{ [testManager sendRequest:testShow]; }).to(raiseException().named(NSInternalInconsistencyException));
});
describe(@"stopping the manager", ^{