mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
checker: make using err.msg and err.code produce an *actual* notice, even with the present compatibility hack (will be *removed* in 2022-06-01)
This commit is contained in:
@ -1863,7 +1863,7 @@ import os
|
||||
|
||||
fn read_log() {
|
||||
mut ok := false
|
||||
mut f := os.open('log.txt') or { panic(err.msg) }
|
||||
mut f := os.open('log.txt') or { panic(err) }
|
||||
defer {
|
||||
f.close()
|
||||
}
|
||||
@ -3452,7 +3452,7 @@ to break from the current block.
|
||||
Note that `break` and `continue` can only be used inside a `for` loop.
|
||||
|
||||
V does not have a way to forcibly "unwrap" an optional (as other languages do,
|
||||
for instance Rust's `unwrap()` or Swift's `!`). To do this, use `or { panic(err.msg) }` instead.
|
||||
for instance Rust's `unwrap()` or Swift's `!`). To do this, use `or { panic(err) }` instead.
|
||||
|
||||
---
|
||||
The third method is to provide a default value at the end of the `or` block.
|
||||
@ -5536,7 +5536,7 @@ eprintln('file: ' + @FILE + ' | line: ' + @LINE + ' | fn: ' + @MOD + '.' + @FN)
|
||||
Another example, is if you want to embed the version/name from v.mod *inside* your executable:
|
||||
```v ignore
|
||||
import v.vmod
|
||||
vm := vmod.decode( @VMOD_FILE ) or { panic(err.msg) }
|
||||
vm := vmod.decode( @VMOD_FILE ) or { panic(err) }
|
||||
eprintln('$vm.name $vm.version\n $vm.description')
|
||||
```
|
||||
|
||||
|
Reference in New Issue
Block a user