mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
builtin: change IError msg
and code
to methods + fix vlib, add a deprecation notice for the old usages (#13041)
This commit is contained in:
@@ -477,14 +477,14 @@ fn (c Checker) check_quoted_escapes(q ast.Quoted) ? {
|
||||
c.check_unicode_escape(s.text[pos..pos + 11]) or {
|
||||
st := s.state()
|
||||
return error(@MOD + '.' + @STRUCT + '.' + @FN +
|
||||
' escaped Unicode is invalid. $err.msg.capitalize() ($st.line_nr,$st.col) in ...${c.excerpt(q.pos)}...')
|
||||
' escaped Unicode is invalid. $err.msg().capitalize() ($st.line_nr,$st.col) in ...${c.excerpt(q.pos)}...')
|
||||
}
|
||||
} else {
|
||||
pos := s.state().pos
|
||||
c.check_unicode_escape(s.text[pos..]) or {
|
||||
st := s.state()
|
||||
return error(@MOD + '.' + @STRUCT + '.' + @FN +
|
||||
' escaped Unicode is invalid. $err.msg.capitalize() ($st.line_nr,$st.col) in ...${c.excerpt(q.pos)}...')
|
||||
' escaped Unicode is invalid. $err.msg().capitalize() ($st.line_nr,$st.col) in ...${c.excerpt(q.pos)}...')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -47,7 +47,7 @@ pub fn (c Config) read_input() ?string {
|
||||
if os.is_file(c.file_path) {
|
||||
text = os.read_file(c.file_path) or {
|
||||
return error(@MOD + '.' + @STRUCT + '.' + @FN +
|
||||
' Could not read "$c.file_path": "$err.msg"')
|
||||
' Could not read "$c.file_path": "$err.msg()"')
|
||||
}
|
||||
}
|
||||
return text
|
||||
|
@@ -55,7 +55,7 @@ pub fn new_scanner(config Config) ?&Scanner {
|
||||
if os.is_file(file_path) {
|
||||
text = os.read_file(file_path) or {
|
||||
return error(@MOD + '.' + @STRUCT + '.' + @FN +
|
||||
' Could not read "$file_path": "$err.msg"')
|
||||
' Could not read "$file_path": "$err.msg()"')
|
||||
}
|
||||
}
|
||||
mut s := &Scanner{
|
||||
|
@@ -155,12 +155,12 @@ fn test_alexcrichton_toml_rs() ? {
|
||||
|
||||
v_normalized_json := run([jq, '-S', '-f "$jq_normalize_path"', v_toml_json_path]) or {
|
||||
contents := os.read_file(v_toml_json_path) ?
|
||||
panic(err.msg + '\n$contents')
|
||||
panic(err.msg() + '\n$contents')
|
||||
}
|
||||
alexcrichton_normalized_json := run([jq, '-S', '-f "$jq_normalize_path"',
|
||||
alexcrichton_toml_json_path]) or {
|
||||
contents := os.read_file(v_toml_json_path) ?
|
||||
panic(err.msg + '\n$contents')
|
||||
panic(err.msg() + '\n$contents')
|
||||
}
|
||||
|
||||
assert alexcrichton_normalized_json == v_normalized_json
|
||||
@@ -199,7 +199,7 @@ fn test_alexcrichton_toml_rs() ? {
|
||||
assert false
|
||||
} else {
|
||||
if !hide_oks {
|
||||
println(' $err.msg')
|
||||
println(' $err.msg()')
|
||||
}
|
||||
assert true
|
||||
}
|
||||
|
@@ -141,11 +141,11 @@ fn test_burnt_sushi_tomltest() ? {
|
||||
|
||||
v_normalized_json := run([jq, '-S', '-f "$jq_normalize_path"', v_toml_json_path]) or {
|
||||
contents := os.read_file(v_toml_json_path) ?
|
||||
panic(err.msg + '\n$contents')
|
||||
panic(err.msg() + '\n$contents')
|
||||
}
|
||||
bs_normalized_json := run([jq, '-S', '-f "$jq_normalize_path"', bs_toml_json_path]) or {
|
||||
contents := os.read_file(v_toml_json_path) ?
|
||||
panic(err.msg + '\n$contents')
|
||||
panic(err.msg() + '\n$contents')
|
||||
}
|
||||
|
||||
assert bs_normalized_json == v_normalized_json
|
||||
@@ -182,7 +182,7 @@ fn test_burnt_sushi_tomltest() ? {
|
||||
assert false
|
||||
} else {
|
||||
if !hide_oks {
|
||||
println(' $err.msg')
|
||||
println(' $err.msg()')
|
||||
}
|
||||
assert true
|
||||
}
|
||||
|
@@ -181,7 +181,7 @@ fn test_iarna_toml_spec_tests() ? {
|
||||
// NOTE there's known errors with the python convertion method.
|
||||
// For now we just ignore them as it's a broken tool - not a wrong test-case.
|
||||
// Uncomment this print to see/check them.
|
||||
// eprintln(err.msg + '\n$contents')
|
||||
// eprintln(err.msg() + '\n$contents')
|
||||
e++
|
||||
println('ERR [${i + 1}/$valid_test_files.len] "$valid_test_file" EXCEPTION [$e/$valid_value_exceptions.len]...')
|
||||
continue
|
||||
@@ -208,12 +208,12 @@ fn test_iarna_toml_spec_tests() ? {
|
||||
|
||||
v_normalized_json := run([jq, '-S', '-f "$jq_normalize_path"', v_toml_json_path]) or {
|
||||
contents := os.read_file(v_toml_json_path) ?
|
||||
panic(err.msg + '\n$contents')
|
||||
panic(err.msg() + '\n$contents')
|
||||
}
|
||||
cmd := [jq, '-S', '-f "$jq_normalize_path"', iarna_toml_json_path]
|
||||
iarna_normalized_json := run(cmd) or {
|
||||
contents := os.read_file(v_toml_json_path) ?
|
||||
panic(err.msg + '\n$contents\n\ncmd: ${cmd.join(' ')}')
|
||||
panic(err.msg() + '\n$contents\n\ncmd: ${cmd.join(' ')}')
|
||||
}
|
||||
|
||||
assert iarna_normalized_json == v_normalized_json
|
||||
@@ -250,7 +250,7 @@ fn test_iarna_toml_spec_tests() ? {
|
||||
assert false
|
||||
} else {
|
||||
if !hide_oks {
|
||||
println(' $err.msg')
|
||||
println(' $err.msg()')
|
||||
}
|
||||
assert true
|
||||
}
|
||||
|
@@ -37,13 +37,13 @@ fn test_toml_with_bom() {
|
||||
// Re-cycle bad_toml_doc
|
||||
mut bad_toml_doc := empty_toml_document
|
||||
bad_toml_doc = toml.parse(toml_text_with_utf16_bom) or {
|
||||
println(' $err.msg')
|
||||
println(' $err.msg()')
|
||||
assert true
|
||||
empty_toml_document
|
||||
}
|
||||
|
||||
bad_toml_doc = toml.parse(toml_text_with_utf32_bom) or {
|
||||
println(' $err.msg')
|
||||
println(' $err.msg()')
|
||||
assert true
|
||||
empty_toml_document
|
||||
}
|
||||
|
Reference in New Issue
Block a user