Add a chapter about errors
One concept that I still find quite hard to grasp are Nushell's errors.
As far as I can tell, they behave like raised exceptions in a language like Python.
They bubble up, but can be caught with try or do -i.
However, I haven't seen that spelled out yet.
I see that nushell errors are also created if external commands exit with a non-zero exit code. But also that isn't mentioned in the book.
I would be happy to add a chapter about errors in Nushell if someone could me guide through the things I am unsure about.
Topics to cover:
- behavior of errors
trydoerror makecomplete
I think this would be a great add. You may want to mention error make and complete as well. It may also be helpful to know that do has undergone some changes recently. So, I'd love some thorough documentation on it. I really don't understand why now you can just use do without the i sometimes.
You may want to mention error make and complete as well
Good point, added it to a list of topics to cover
It may also be helpful to know that do has undergone some changes recently. So, I'd love some thorough documentation on it. I really don't understand why now you can just use do without the i sometimes.
Not sure what you mean there, at the moment, do takes a closure and can optionally accept command line flags according to the docs.
Regarding exceptions. Is there any relevant difference to exceptions in other languages which should be pointed out?
Not sure what you mean there, at the moment,
There used to be a difference between these two commands (not in a directory with a git repo). Now there doesn't appear to be.
do -i { git branch --show-current }
and
do { git branch --show-current }
and with capturing the output.
do -i { git branch --show-current } | complete
and
do { git branch --show-current } | complete
@fdncred I can see the following difference
# test1.nu
do { git branch --show-current }
echo Hello
$ nu test1.nu
fatal: not a git repository (or any of the parent directories): .git
# test2.nu
do -i { git branch --show-current }
echo Hello
$ test2.nu
fatal: not a git repository (or any of the parent directories): .git
Hello
That's great that you've found a difference. Whatever all the differences are in those do commands should be documented.