Skip to content

Better error checking in module loading #25

@JohnOmernik

Description

@JohnOmernik

When modules paths are checked in go-script-bash/lib/internal/use basically the script tries to source them and if it fails, it just ends up on unknown module

if ! . "$_GO_CORE_DIR/lib/$__go_module_name" 2>/dev/null &&
! . "$_GO_SCRIPTS_DIR/plugins/${__go_module_name////lib/}" 2>/dev/null &&
! . "$_GO_SCRIPTS_DIR/lib/$__go_module_name" 2>/dev/null; then
@go.printf "ERROR: Unknown module: $__go_module_name" >&2
exit 1
fi

However, this doesn't differentiate between the module not existing, and the module having an error. I.e. if the module file exists, but has a bash syntax error, it will fail with the same "Unknown module" error that it fails with if the module file doesn't exist.

Ideally, we'd have two messages, one for issue with the module file not existing, another stating the file doesn't exist, however there was an error in loading it.

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions