• Stars
    star
    64
  • Rank 479,282 (Top 10 %)
  • Language
    Shell
  • License
    MIT License
  • Created almost 8 years ago
  • Updated over 7 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Proper error handling, exceptions and try/catch for ZSH

Crash

Build Status Join the chat at https://gitter.im/molovo/crash

Proper error handling, exceptions and try/catch for ZSH.

Crash Screenshot

Installation

zulu install crash

Manual

git clone https://github.com/molovo/crash crash
cp crash/crash /usr/local/share/zsh/site-functions # Or anywhere else in $fpath

Usage

Set up the global error handler

Crash comes with a global error handler, which prints a readable error and stack trace both for user-created exceptions and traditional shell exit codes.

autoload -Uz crash && crash register

throw TestException 'This is a test' # Will cause the error handler to be displayed

Try/catch

Crash comes with the functions try, catch and throw, allowing you to handle exceptions much as you would in a 'proper' programming language.

autoload -Uz crash && crash register

# The function we're going to call
function do_something() {
  echo 'Start to do something...'
  throw RainbowException 'Unicorns!'
  echo 'This message will never be displayed'
}

# A function to handle any caught exceptions
function error_handler() {
  local exception="$1" message="${(@)@:2}"

  echo $exception # RainbowException
  echo $message   # Unicorns!
}

try do_something
catch RainbowException error_handler

License

Copyright (c) 2016 James Dinsdale [email protected] (molovo.co)

Crash is licensed under The MIT License (MIT)

Team

More Repositories

1

revolver

A progress spinner for ZSH scripts
Shell
143
star
2

lumberjack

Lumberjack is a logging interface for shell scripts
Shell
43
star
3

filthy

A disgustingly clean ZSH prompt
Shell
43
star
4

bushwick

# Bushwick
CSS
31
star
5

tipz

Gives you helpful hints when you execute a command for which you have an alias defined
Shell
27
star
6

browserWrapper

browserWrapper plugin, by @molovo
CSS
21
star
7

zlint

A linter and code style checker for ZSH
Shell
16
star
8

taken

An anchor CMS theme
CSS
15
star
9

zvm

The ZSH version manager
Shell
13
star
10

roots-image-pipeline

Image pipeline plugin for Roots (http://roots.cx)
CoffeeScript
13
star
11

color

A small zsh script for styling strings
Shell
12
star
12

sublime-zsh

Provides native ZSH autocompletion and snippets
Shell
11
star
13

anchor-comments

A plugin utilising the existing Anchor CMS comments functionality to provide inline comments within articles.
JavaScript
10
star
14

herd

A simple module to help with running multi-threaded processes in Crystal
Crystal
7
star
15

browserWrapper-lite

CSS
6
star
16

crayon

A collection of helpers for building pretty command-line tools in Crystal.
Crystal
6
star
17

zshbuild

A helper tool for building large ZSH projects from source
Shell
5
star
18

micro-stripe-payment

An asynchronous HTTP micro-service for accepting Stripe payments on static sites.
JavaScript
4
star
19

consumer

A tiny REST API consumer for JavaScript projects
JavaScript
4
star
20

accidents

Pretty error handling for command-line PHP apps.
PHP
4
star
21

.files

Vim Script
3
star
22

melody

A simple SASS framework
CSS
3
star
23

tiny

A Crystal module to help you build multi-threaded HTTP micro-services
Crystal
3
star
24

www

Sass
2
star
25

magic-roundabout

A tiny JavaScript carousel
JavaScript
2
star
26

done

A simple helper script to send a notification when a long-running command completes
Shell
2
star
27

graphite

A collection of helpers for building pretty command-line tools in PHP.
PHP
2
star
28

browserWrapper-site

HTML
2
star
29

live-node-list

An alternative to NodeList which keeps collections up to date when changes to the DOM occur
JavaScript
2
star
30

alternatone-stark-sea-syntax

CSS
1
star
31

timeme

TimeMe,
JavaScript
1
star
32

phake

A PHP task runner inspired by Make, Rake et al.
PHP
1
star
33

crsh

Crystal
1
star
34

object

HTML
1
star
35

Dates

A polyfill to recreate Google Chrome's keyboard input behaviour on date inputs across other browsers
JavaScript
1
star
36

insert-sudo

A little zsh snippet to prepend sudo to the current command
Shell
1
star
37

amnesia

A lightweight, standalone caching library for PHP 5.5+
PHP
1
star
38

load-graph

Shell
1
star
39

interrogate

A lightweight, standalone ORM for PHP 5.5+
PHP
1
star
40

dateme

Simple, non-invasive JavaScript date sanitisation.
JavaScript
1
star