Skip to content

Commit

Permalink
use a Flag!"throwOnError" for Curl.perform
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinNowak committed Nov 22, 2014
1 parent 7e80e67 commit 99ba1e1
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions std/net/curl.d
Expand Up @@ -2238,7 +2238,7 @@ struct HTTP
_perform();
}

private CurlCode _perform(bool throwOnError = true)
private CurlCode _perform(ThrowOnError throwOnError = ThrowOnError.yes)
{
p.status.reset();

Expand Down Expand Up @@ -2945,7 +2945,7 @@ struct FTP
_perform();
}

private CurlCode _perform(bool throwOnError = true)
private CurlCode _perform(ThrowOnError throwOnError = ThrowOnError.yes)
{
return p.curl.perform(throwOnError);
}
Expand Down Expand Up @@ -3556,6 +3556,10 @@ class CurlTimeoutException : CurlException
/// Equal to $(ECXREF curl, CURLcode)
alias CurlCode = CURLcode;

import std.typecons : Flag;
/// Flag to specify whether or not an exception is thrown on error.
alias ThrowOnError = Flag!"throwOnError";

/**
Wrapper to provide a better interface to libcurl than using the plain C API.
It is recommended to use the $(D HTTP)/$(D FTP) etc. structs instead unless
Expand Down Expand Up @@ -3788,8 +3792,11 @@ struct Curl
/**
perform the curl request by doing the HTTP,FTP etc. as it has
been setup beforehand.
Params:
throwOnError = whether to throw an exception or return a CurlCode on error
*/
CurlCode perform(bool throwOnError = true)
CurlCode perform(ThrowOnError throwOnError = ThrowOnError.yes)
{
throwOnStopped();
CurlCode code = curl_easy_perform(this.handle);
Expand All @@ -3798,6 +3805,13 @@ struct Curl
return code;
}

// Explicitly undocumented. It will be removed in November 2015.
deprecated("Pass ThrowOnError.yes or .no instead of a boolean.")
CurlCode perform(bool throwOnError)
{
return perform(cast(ThrowOnError)throwOnError);
}

/**
* The event handler that receives incoming data.
*
Expand Down

0 comments on commit 99ba1e1

Please sign in to comment.