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

Update boot.sh - show exception message #27

Open
lopesivan opened this issue Apr 29, 2017 · 0 comments
Open

Update boot.sh - show exception message #27

lopesivan opened this issue Apr 29, 2017 · 0 comments

Comments

@lopesivan
Copy link

lopesivan commented Apr 29, 2017

boot.sh

## Raises an exception that can be caught by catch statement
## @param exception - a string containing the name of the exception
function b.raise () {
  local exception="$1"
  shift
  if echo "${FUNCNAME[@]}" | grep -q 'b.try.do'; then

    local function=$(echo ${FUNCNAME[1]} |
      sed -e 's/^_\([^.]\+\)\..*/\1/')

    function=${function}.exception.$(echo $exception |
      sed -e 's/\([A-Z]\)/_\L\1/g' -e 's/^_//' -e 's/_exception//')

    echo 'function :' `tput bold`${FUNCNAME[1]}`tput sgr0`
    echo 'exception:' "$exception"
    echo -n 'message  : '
    tput bold
    tput setb 3
    tput setaf 3
    $function
    tput sgr0

    b.set "Bang.Exception.Name" "$exception"
    b.set "Bang.Exception.Msg" "$*"
  else
    b.abort "Uncaught exception $exception: $*"
  fi
}

example:

Outout

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant