{"id":18794334,"url":"https://github.com/redplanetlabs/defexception","last_synced_at":"2025-04-05T23:09:23.651Z","repository":{"id":46719015,"uuid":"203626683","full_name":"redplanetlabs/defexception","owner":"redplanetlabs","description":"A simple Clojure library to dynamically define Java Exception classes in Clojure.","archived":false,"fork":false,"pushed_at":"2022-11-04T19:05:34.000Z","size":37,"stargazers_count":120,"open_issues_count":0,"forks_count":7,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-03-29T22:06:53.381Z","etag":null,"topics":["clojure","clojure-library"],"latest_commit_sha":null,"homepage":"","language":"Clojure","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"epl-1.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/redplanetlabs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-08-21T16:48:55.000Z","updated_at":"2025-03-05T18:50:04.000Z","dependencies_parsed_at":"2023-01-21T01:16:45.767Z","dependency_job_id":null,"html_url":"https://github.com/redplanetlabs/defexception","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/redplanetlabs%2Fdefexception","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/redplanetlabs%2Fdefexception/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/redplanetlabs%2Fdefexception/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/redplanetlabs%2Fdefexception/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/redplanetlabs","download_url":"https://codeload.github.com/redplanetlabs/defexception/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247411235,"owners_count":20934653,"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":["clojure","clojure-library"],"created_at":"2024-11-07T21:29:03.148Z","updated_at":"2025-04-05T23:09:23.598Z","avatar_url":"https://github.com/redplanetlabs.png","language":"Clojure","funding_links":[],"categories":[],"sub_categories":[],"readme":"# defexception\n[![Build Status](https://travis-ci.org/redplanetlabs/defexception.svg?branch=master)](https://travis-ci.org/redplanetlabs/defexception)\n[![Clojars Project](https://img.shields.io/clojars/v/com.rpl/defexception.svg)](https://clojars.org/com.rpl/defexception)\n[![cljdoc\nbadge](https://cljdoc.org/badge/com.rpl/defexception)](https://cljdoc.org/d/com.rpl/defexception/CURRENT)\n\nA simple Clojure library that allows one to dynamically define Java Exception classes in Clojure.\n\n## Motivation\n\nSometimes you just want a quick Exception class that you can catch\ndirectly. `defexception` uses Java bytecode to dynamically create a\nJava class that directly inherits from `clojure.lang.ExceptionInfo`.\n\nThe created exception class does not add any behavior to `clojure.lang.ExceptionInfo`.\n\n## Dependency\n\n\n[deps.edn](https://clojure.org/guides/deps_and_cli) dependency information:\n\n```\ncom.rpl/defexception {:mvn/version \"0.2.5\"}\n```\n\n[Leiningen](https://github.com/technomancy/leiningen/) dependency information:\n\n```\n[com.rpl/defexception \"0.2.5\"]\n```\n\n## Usage\n\nTo create your own exception class you can do this:\n\n```clojure\n(ns foo.bar\n (:require [com.rpl.defexception :refer [defexception]]))\n\n(defexception MyException)\n```\n\nThis will create the `foo.bar.MyException` class that inherits from\n`clojure.lang.ExceptionInfo`. This will also `import` the class into\nthe current namespace and create a helper function\n`foo.bar/-\u003eMyException` to help you construct the exception class.\n\nNow you can do this:\n\n```clojure\n(try\n  (throw (-\u003eMyException \"My bad!\" {:my-bad 1}))\n  (catch MyException e\n    (ex-data e)))\n;; =\u003e {:my-bad 1}\n```\n\nThe generated `-\u003eMyException` helper function has several signatures\nto help you instantiate your exception.\n\n```clojure\n;; creates an exception with no message or ex-data\n(-\u003eMyException)\n\n;; creates an exception with only ex-data\n(-\u003eMyException {:hello 1})\n\n;; creates an exception with only a message\n(-\u003eMyException \"My Bad!\")\n\n;; creates an exception with both a message and ex-data\n(-\u003eMyException \"My Bad!\" {:hello 1})\n\n;; creates an exception with a message, ex-data and a cause\n(-\u003eMyException \"My Bad!\" {:hello 1} (Exception. \"The cause\"))\n```\n\n## AOT compilation\n\nCare was taken to make these exceptions compatible with Clojure's AOT\ncompilation.\n\n## License\n\nCopyright © 2019 - 2020 Red Planet Labs Inc.\n\nDistributed under the Eclipse Public License version 1.0\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fredplanetlabs%2Fdefexception","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fredplanetlabs%2Fdefexception","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fredplanetlabs%2Fdefexception/lists"}