http: make download_file() return an optional
parent
a042966082
commit
98034e5504
|
@ -5,14 +5,13 @@ module http
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
pub fn download_file(url string, out string) bool {
|
pub fn download_file(url string, out string)? {
|
||||||
$if debug_http? {
|
$if debug_http? {
|
||||||
println('download file url=$url out=$out')
|
println('download file url=$url out=$out')
|
||||||
}
|
}
|
||||||
s := get(url) or {
|
s := get(url) or {
|
||||||
return false
|
return error(err)
|
||||||
}
|
}
|
||||||
os.write_file(out, s.text)
|
os.write_file(out, s.text)
|
||||||
return true
|
|
||||||
// download_file_with_progress(url, out, empty, empty)
|
// download_file_with_progress(url, out, empty, empty)
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,7 +49,7 @@ $dec_fn_dec {
|
||||||
if (!root) {
|
if (!root) {
|
||||||
const char *error_ptr = cJSON_GetErrorPtr();
|
const char *error_ptr = cJSON_GetErrorPtr();
|
||||||
if (error_ptr != NULL) {
|
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);
|
// printf("\\nbad js=%%s\\n", js.str);
|
||||||
Option err = v_error(tos2(error_ptr));
|
Option err = v_error(tos2(error_ptr));
|
||||||
return *(Option_$styp *)&err;
|
return *(Option_$styp *)&err;
|
||||||
|
|
Loading…
Reference in New Issue