Handle and return errors in internal/config/
The following discussion from !431 (merged) should be addressed:
-
@ash2k started a discussion: Here and in other places - I think it's not the best design choice when a static function terminates the whole process. Some of the reasons off the top of my head:
- It's hard to reason about such code as the function call site does not tell the reader this would happen - signature does not reveal it might stop the program. It's much cleaner to return an error and log, capture error, etc and then exit in
main()
. -
defer
ed functions will not be called and no required cleanup (if any) will be performed. - Some code might need to be duplicated in each place where function terminates the program - e.g. error capturing is duplicated in a few places when it could have been done centrally.
I understand that this code was simply moved from one place to the other and that you folks probably know what I'm saying, but I decided to leave the comment anyway, for completeness :)
- It's hard to reason about such code as the function call site does not tell the reader this would happen - signature does not reveal it might stop the program. It's much cleaner to return an error and log, capture error, etc and then exit in