Improved error handling

Signed-off-by: David Noble <dnoble@splunk.com>