nvim-neorg / neorg

Modernity meets insane extensibility. The future of organizing your life in Neovim.
GNU General Public License v3.0
6.36k stars 209 forks source link

[Codebase]: Use Lua errors #1355

Open vhyrro opened 6 months ago

vhyrro commented 6 months ago

Throughout the codebase we use our in-house logger. This is great for most cases, although makes error handling pretty tricky (requiring us to return nil values or error values instead of yielding proper errors).

Lua has error handling built in and even though it might not be the best in the world, it is much better than our current system.

This would require a rewrite of large portions of the codebase. Functions would properly invoke the standard error() function whenever something went wrong, allowing functions higher up the call stack to intercept the error and handle it appropriately.

It might even be possible to create a general error handling library inspired by sum types or Zig's error handling scheme. This library could be pushed to luarocks for everyone to use. I'm happy to hear some thoughts :)

pysan3 commented 6 months ago

Fully agree. A separate library would be awesome IMO.