1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

docs, builtin, encoding.csv: update error implementations (#13440)

This commit is contained in:
Tim Basel
2022-02-12 10:54:10 +01:00
committed by GitHub
parent ae0e90f5d8
commit 37c151efe5
6 changed files with 81 additions and 37 deletions

View File

@ -35,8 +35,9 @@ pub fn (err IError) str() string {
}
else {
// >> Hack to allow old style custom error implementations
// TODO: can be removed once the checker 'hacks' are merged (so `vc` has them included)
if !isnil(err.msg) {
// TODO: remove once deprecation period for `IError` methods has ended
old_error_style := unsafe { voidptr(&err.msg) != voidptr(&err.code) } // if fields are not defined (new style) they don't have an offset between them
if old_error_style {
'$err.type_name(): $err.msg'
} else {
// <<
@ -47,13 +48,7 @@ pub fn (err IError) str() string {
}
// Error is the empty default implementation of `IError`.
pub struct Error {
// >> Hack to allow old style custom error implementations
// TODO: can be removed once the checker 'hacks' are merged (so `vc` has them included)
msg string
code int
/// <<
}
pub struct Error {}
pub fn (err Error) msg() string {
return ''