Exception objects should be thrown and not the pointer to the exception object. (#322)
Exception objects should be thrown and not the pointer to the exception object. https://azure.github.io/azure-sdk/cpp_design.html#c-exceptions The pattern for the catch expects a reference to the exception and not the pointer. Example: try{ throw Myxception(); } catch (MyException const& e) { //process }
This commit is contained in:
parent
b69080bc48
commit
bbbaa06b5c
@ -194,10 +194,10 @@ AccessToken ClientSecretCredential::GetToken(
|
||||
}
|
||||
catch (std::exception const& e)
|
||||
{
|
||||
throw new AuthenticationException(e.what());
|
||||
throw AuthenticationException(e.what());
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
throw new AuthenticationException("unknown error");
|
||||
throw AuthenticationException("unknown error");
|
||||
}
|
||||
}
|
||||
|
||||
@ -21,12 +21,12 @@ std::unique_ptr<Response> CurlTransport::Send(Context& context, Request& request
|
||||
{
|
||||
case CURLE_COULDNT_RESOLVE_HOST:
|
||||
{
|
||||
throw new Azure::Core::Http::CouldNotResolveHostException(
|
||||
throw Azure::Core::Http::CouldNotResolveHostException(
|
||||
"Could not resolve host " + request.GetHost());
|
||||
}
|
||||
default:
|
||||
{
|
||||
throw new Azure::Core::Http::TransportException(
|
||||
throw Azure::Core::Http::TransportException(
|
||||
"Error while sending request. " + std::string(curl_easy_strerror(performing)));
|
||||
}
|
||||
}
|
||||
@ -524,15 +524,15 @@ int64_t CurlSession::ReadSocketToBuffer(uint8_t* buffer, int64_t bufferSize)
|
||||
if (!WaitForSocketReady(this->m_curlSocket, 0, 60000L))
|
||||
{
|
||||
// TODO: Change this to somehing more relevant
|
||||
throw new Azure::Core::Http::TransportException(
|
||||
throw Azure::Core::Http::TransportException(
|
||||
"Timeout waiting to read from Network socket");
|
||||
}
|
||||
break;
|
||||
case CURLE_OK:
|
||||
break;
|
||||
default:
|
||||
// Error code while reading from socket
|
||||
throw new Azure::Core::Http::TransportException("Error while reading from network socket");
|
||||
// Error reading from socket
|
||||
throw Azure::Core::Http::TransportException("Error while reading from network socket");
|
||||
}
|
||||
}
|
||||
return readBytes;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user