Modules/cURL/curl strerror: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Created page with "__NOTOC__ {{ModuleFunction|cURL}} Returns a string with detailed information of an error. ==Syntax== <syntaxhighlight lang="lua"> curl_strerror(curl handler, CURLcode code) </syntaxhighlight> ==Required...")
 
No edit summary
 
(One intermediate revision by one other user not shown)
Line 5: Line 5:
==Syntax==
==Syntax==
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
curl_strerror(curl handler, CURLcode code)
curlStrerror(curl handler, CURLcode code)
</syntaxhighlight>
</syntaxhighlight>


Line 17: Line 17:
==Example==
==Example==
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
curl = curl_init();
curl = curlInit();
if not curl then
if not curl then
     outputDebugString("Can't connect to http://mtasa.com/ with cURL");
     outputDebugString("Can't connect to http://mtasa.com/ with cURL");
else
else
     curl_setopt(curl, CURLOPT_URL, curl_escape(curl, "http://mtasa.com/"));
     curlSetopt(curl, CURLOPT_URL, curlEscape(curl, "http://mtasa.com/"));
     result = curl_perform(curl, {
     result = curlPerform(curl);
        writefunction = function(html)
     print(curlStrerror(curl, result)); -- Since we know that mta exists, we sure get the text 'No error.'
            -- Hell what should i do with html? :S
     curlClose(curl);
        end,
    });
     print(curl_strerror(curl, result)); -- Since we know that mta exists, we sure get the text 'No error.'
     curl_close(curl);
end
end
</syntaxhighlight>
</syntaxhighlight>
Line 35: Line 31:
==See also==
==See also==
{{Modules/cURL/functions}}
{{Modules/cURL/functions}}
[[Category:Modules]]

Latest revision as of 11:12, 22 June 2014


Package-x-generic.png This function is provided by the external module cURL. You must install this module to use this function.

Returns a string with detailed information of an error.

Syntax

curlStrerror(curl handler, CURLcode code)

Required arguments

  • curl The curl handler
  • code The curl code

Returns

The string containing the error, if the code was not found in the system it will return nil

Example

curl = curlInit();
if not curl then
    outputDebugString("Can't connect to http://mtasa.com/ with cURL");
else
    curlSetopt(curl, CURLOPT_URL, curlEscape(curl, "http://mtasa.com/"));
    result = curlPerform(curl);
    print(curlStrerror(curl, result)); -- Since we know that mta exists, we sure get the text 'No error.'
    curlClose(curl);
end


See also