mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
http: make download_file() return an optional
This commit is contained in:
parent
a042966082
commit
98034e5504
@ -5,14 +5,13 @@ module http
|
||||
|
||||
import os
|
||||
|
||||
pub fn download_file(url string, out string) bool {
|
||||
pub fn download_file(url string, out string)? {
|
||||
$if debug_http? {
|
||||
println('download file url=$url out=$out')
|
||||
}
|
||||
s := get(url) or {
|
||||
return false
|
||||
return error(err)
|
||||
}
|
||||
os.write_file(out, s.text)
|
||||
return true
|
||||
// download_file_with_progress(url, out, empty, empty)
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ $dec_fn_dec {
|
||||
if (!root) {
|
||||
const char *error_ptr = cJSON_GetErrorPtr();
|
||||
if (error_ptr != NULL) {
|
||||
// fprintf(stderr, "Error in decode() for $styp error_ptr=: %%s\\n", error_ptr);
|
||||
// fprintf(stderr, "Error in decode() for $styp error_ptr=: %s\\n", error_ptr);
|
||||
// printf("\\nbad js=%%s\\n", js.str);
|
||||
Option err = v_error(tos2(error_ptr));
|
||||
return *(Option_$styp *)&err;
|
||||
|
Loading…
Reference in New Issue
Block a user