mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
all: update repo to use the new error handling syntax (#8950)
This commit is contained in:
@@ -56,7 +56,7 @@ fn (mut dtp DTP) read() ?[]byte {
|
||||
}
|
||||
|
||||
fn (mut dtp DTP) close() {
|
||||
dtp.conn.close() or { panic(err) }
|
||||
dtp.conn.close() or { panic(err.msg) }
|
||||
}
|
||||
|
||||
struct FTP {
|
||||
|
||||
@@ -8,14 +8,14 @@ fn test_ftp_cleint() {
|
||||
// that is why it is not a very good idea to run it in CI.
|
||||
// If you want to run it manually, use:
|
||||
// `v -d network vlib/net/ftp/ftp_test.v`
|
||||
ftp_client_test_inside() or { panic(err) }
|
||||
ftp_client_test_inside() or { panic(err.msg) }
|
||||
}
|
||||
|
||||
fn ftp_client_test_inside() ? {
|
||||
mut zftp := ftp.new()
|
||||
// eprintln(zftp)
|
||||
defer {
|
||||
zftp.close() or { panic(err) }
|
||||
zftp.close() or { panic(err.msg) }
|
||||
}
|
||||
connect_result := zftp.connect('ftp.redhat.com') ?
|
||||
assert connect_result
|
||||
|
||||
@@ -25,7 +25,7 @@ mut:
|
||||
fn (mut dom DocumentObjectModel) print_debug(data string) {
|
||||
$if debug {
|
||||
if data.len > 0 {
|
||||
dom.debug_file.writeln(data) or { panic(err) }
|
||||
dom.debug_file.writeln(data) or { panic(err.msg) }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ fn (parser Parser) builder_str() string {
|
||||
fn (mut parser Parser) print_debug(data string) {
|
||||
$if debug {
|
||||
if data.len > 0 {
|
||||
parser.debug_file.writeln(data) or { panic(err) }
|
||||
parser.debug_file.writeln(data) or { panic(err.msg) }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ pub fn download_file(url string, out string) ? {
|
||||
$if debug_http ? {
|
||||
println('download file url=$url out=$out')
|
||||
}
|
||||
s := get(url) or { return error(err) }
|
||||
s := get(url) or { return err }
|
||||
os.write_file(out, s.text) ?
|
||||
// download_file_with_progress(url, out, empty, empty)
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ fn http_fetch_mock(_methods []string, _config FetchConfig) ?[]Response {
|
||||
fn test_http_fetch_bare() {
|
||||
$if !network ? { return }
|
||||
responses := http_fetch_mock([], FetchConfig{}) or {
|
||||
panic(err)
|
||||
panic(err.msg)
|
||||
}
|
||||
for response in responses {
|
||||
assert response.status_code == 200
|
||||
@@ -46,11 +46,11 @@ fn test_http_fetch_with_data() {
|
||||
responses := http_fetch_mock(['POST', 'PUT', 'PATCH', 'DELETE'], {
|
||||
data: 'hello world'
|
||||
}) or {
|
||||
panic(err)
|
||||
panic(err.msg)
|
||||
}
|
||||
for response in responses {
|
||||
payload := json.decode(HttpbinResponseBody,response.text) or {
|
||||
panic(err)
|
||||
panic(err.msg)
|
||||
}
|
||||
assert payload.data == 'hello world'
|
||||
}
|
||||
@@ -64,11 +64,11 @@ fn test_http_fetch_with_params() {
|
||||
'c': 'd'
|
||||
}
|
||||
}) or {
|
||||
panic(err)
|
||||
panic(err.msg)
|
||||
}
|
||||
for response in responses {
|
||||
// payload := json.decode(HttpbinResponseBody,response.text) or {
|
||||
// panic(err)
|
||||
// panic(err.msg)
|
||||
// }
|
||||
assert response.status_code == 200
|
||||
// TODO
|
||||
@@ -84,11 +84,11 @@ fn test_http_fetch_with_headers() {
|
||||
'Test-Header': 'hello world'
|
||||
}
|
||||
}) or {
|
||||
panic(err)
|
||||
panic(err.msg)
|
||||
}
|
||||
for response in responses {
|
||||
// payload := json.decode(HttpbinResponseBody,response.text) or {
|
||||
// panic(err)
|
||||
// panic(err.msg)
|
||||
// }
|
||||
assert response.status_code == 200
|
||||
// TODO
|
||||
|
||||
@@ -16,7 +16,7 @@ fn test_http_get_from_vlang_utc_now() {
|
||||
for url in urls {
|
||||
println('Test getting current time from $url by http.get')
|
||||
res := http.get(url) or {
|
||||
panic(err)
|
||||
panic(err.msg)
|
||||
}
|
||||
assert 200 == res.status_code
|
||||
assert res.text.len > 0
|
||||
@@ -40,7 +40,7 @@ fn test_public_servers() {
|
||||
for url in urls {
|
||||
println('Testing http.get on public url: $url ')
|
||||
res := http.get(url) or {
|
||||
panic(err)
|
||||
panic(err.msg)
|
||||
}
|
||||
assert 200 == res.status_code
|
||||
assert res.text.len > 0
|
||||
@@ -54,7 +54,7 @@ fn test_relative_redirects() {
|
||||
return
|
||||
} // tempfix periodic: httpbin relative redirects are broken
|
||||
res := http.get('https://httpbin.org/relative-redirect/3?abc=xyz') or {
|
||||
panic(err)
|
||||
panic(err.msg)
|
||||
}
|
||||
assert 200 == res.status_code
|
||||
assert res.text.len > 0
|
||||
|
||||
@@ -7,9 +7,9 @@ const (
|
||||
)
|
||||
|
||||
fn setup() (&net.TcpListener, &net.TcpConn, &net.TcpConn) {
|
||||
mut server := net.listen_tcp(server_port) or { panic(err) }
|
||||
mut client := net.dial_tcp('127.0.0.1:$server_port') or { panic(err) }
|
||||
mut socket := server.accept() or { panic(err) }
|
||||
mut server := net.listen_tcp(server_port) or { panic(err.msg) }
|
||||
mut client := net.dial_tcp('127.0.0.1:$server_port') or { panic(err.msg) }
|
||||
mut socket := server.accept() or { panic(err.msg) }
|
||||
$if debug_peer_ip ? {
|
||||
ip := con.peer_ip() or { '$err' }
|
||||
eprintln('connection peer_ip: $ip')
|
||||
|
||||
@@ -44,8 +44,8 @@ fn echo() ? {
|
||||
}
|
||||
|
||||
fn test_tcp() {
|
||||
mut l := net.listen_tcp(test_port) or { panic(err) }
|
||||
mut l := net.listen_tcp(test_port) or { panic(err.msg) }
|
||||
go echo_server(mut l)
|
||||
echo() or { panic(err) }
|
||||
echo() or { panic(err.msg) }
|
||||
l.close() or { }
|
||||
}
|
||||
|
||||
@@ -51,8 +51,8 @@ fn echo() ? {
|
||||
}
|
||||
|
||||
fn test_tcp() {
|
||||
mut l := unix.listen_stream(test_port) or { panic(err) }
|
||||
mut l := unix.listen_stream(test_port) or { panic(err.msg) }
|
||||
go echo_server(mut l)
|
||||
echo() or { panic(err) }
|
||||
echo() or { panic(err.msg) }
|
||||
l.close() or { }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user