Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create an Error Code list #30

Open
andrewwoods opened this issue Mar 25, 2024 · 0 comments
Open

Create an Error Code list #30

andrewwoods opened this issue Mar 25, 2024 · 0 comments
Labels
Feature A group of related tasks

Comments

@andrewwoods
Copy link
Owner

Description

The shell uses an integer value 1-127 to represent failure. Establish an error array that can be reused accross function to provide consistent values. This will help with debugging.

Expected Outcome

What do you think should happen?

Create an associative array , where an error code string is the key and the integer is the value. Write each entry on its own line for easier maintenance.

Consider creating bash functions to check for an entry and to get a value.

  • opal:error_by_name
  • opal:error_by_value
  • opal:error_exists
declare -A opal_error=([GENERIC_ERROR]=1 [FILE_NOT_READABLE]=2 [FILE_NOT_WRITABLE]=3 [ARGUMENT_MISSING]=4 )

Describe alternatives you've considered

Considered using individual error variables export OPAL_GENERIC_ERROR=1. This would be ok for a few error codes, but as N grows, it pollutes the environment. By
declaring an array, only a single name is used, opal_error.

@andrewwoods andrewwoods added the Feature A group of related tasks label Mar 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature A group of related tasks
Projects
None yet
Development

No branches or pull requests

1 participant