Skip to content

Create an Error Code list #30

@andrewwoods

Description

@andrewwoods

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    FeatureA group of related tasks

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions