{"id":16617128,"url":"https://github.com/molovo/crash","last_synced_at":"2025-03-21T14:31:28.220Z","repository":{"id":153210962,"uuid":"80669789","full_name":"molovo/crash","owner":"molovo","description":"Proper error handling, exceptions and try/catch for ZSH","archived":false,"fork":false,"pushed_at":"2017-03-28T21:47:54.000Z","size":162,"stargazers_count":66,"open_issues_count":1,"forks_count":4,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-18T02:12:21.789Z","etag":null,"topics":["exception-handler","exceptions","zsh","zsh-plugin","zsh-plugins"],"latest_commit_sha":null,"homepage":null,"language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/molovo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2017-02-01T22:13:26.000Z","updated_at":"2025-03-17T00:09:25.000Z","dependencies_parsed_at":"2024-01-03T04:12:48.235Z","dependency_job_id":"1c851a41-f69b-4e41-931b-7a61fafe25c1","html_url":"https://github.com/molovo/crash","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/molovo%2Fcrash","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/molovo%2Fcrash/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/molovo%2Fcrash/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/molovo%2Fcrash/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/molovo","download_url":"https://codeload.github.com/molovo/crash/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244815197,"owners_count":20514912,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["exception-handler","exceptions","zsh","zsh-plugin","zsh-plugins"],"created_at":"2024-10-12T02:15:26.519Z","updated_at":"2025-03-21T14:31:27.912Z","avatar_url":"https://github.com/molovo.png","language":"Shell","funding_links":[],"categories":["Plugins","Shell Script Development"],"sub_categories":["ZSH on Windows","Zinit (née zplugin)","Directory Navigation"],"readme":"# Crash\n\n[![Build Status](https://travis-ci.org/molovo/crash.svg?branch=master)](https://travis-ci.org/molovo/crash)\n[![Join the chat at https://gitter.im/molovo/crash](https://badges.gitter.im/molovo/crash.svg)](https://gitter.im/molovo/crash?utm_source=badge\u0026utm_medium=badge\u0026utm_campaign=pr-badge\u0026utm_content=badge)\n\nProper error handling, exceptions and try/catch for ZSH.\n\n![Crash Screenshot](/screenshots/screenshot.png)\n\n## Installation\n\n### [zulu](https://github.com/zulu-zsh/zulu)\n\n```sh\nzulu install crash\n```\n\n### Manual\n\n```sh\ngit clone https://github.com/molovo/crash crash\ncp crash/crash /usr/local/share/zsh/site-functions # Or anywhere else in $fpath\n```\n\n## Usage\n\n### Set up the global error handler\n\nCrash comes with a global error handler, which prints a readable error and stack trace both for user-created exceptions and traditional shell exit codes.\n\n```sh\nautoload -Uz crash \u0026\u0026 crash register\n\nthrow TestException 'This is a test' # Will cause the error handler to be displayed\n```\n\n### Try/catch\n\nCrash comes with the functions `try`, `catch` and `throw`, allowing you to handle exceptions much as you would in a 'proper' programming language.\n\n```sh\nautoload -Uz crash \u0026\u0026 crash register\n\n# The function we're going to call\nfunction do_something() {\n  echo 'Start to do something...'\n  throw RainbowException 'Unicorns!'\n  echo 'This message will never be displayed'\n}\n\n# A function to handle any caught exceptions\nfunction error_handler() {\n  local exception=\"$1\" message=\"${(@)@:2}\"\n\n  echo $exception # RainbowException\n  echo $message   # Unicorns!\n}\n\ntry do_something\ncatch RainbowException error_handler\n```\n\n## License\n\nCopyright (c) 2016 James Dinsdale \u003chi@molovo.co\u003e (molovo.co)\n\nCrash is licensed under The MIT License (MIT)\n\n## Team\n\n* [James Dinsdale](http://molovo.co)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmolovo%2Fcrash","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmolovo%2Fcrash","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmolovo%2Fcrash/lists"}