All Projects → mpenet → ex

mpenet / ex

Licence: other
Exception net

Programming Languages

clojure
4091 projects

Projects that are alternatives of or similar to ex

Graphql Errors
Simple error handler for GraphQL Ruby ❗️
Stars: ✭ 170 (+900%)
Mutual labels:  exception-handling
bugsnag-java
Bugsnag error reporting for Java.
Stars: ✭ 51 (+200%)
Mutual labels:  exception-handling
quarkus-resteasy-problem
Unified error responses for Quarkus REST APIs via Problem Details for HTTP APIs (RFC7807). Supports Quarkus 2.0+ and 1.4+
Stars: ✭ 36 (+111.76%)
Mutual labels:  exception-handling
Exceptions4c
🐑 An exception handling framework for C
Stars: ✭ 189 (+1011.76%)
Mutual labels:  exception-handling
cakephp-error-email
ErrorEmail Plugin for CakePHP3.x
Stars: ✭ 16 (-5.88%)
Mutual labels:  exception-handling
AspNetCore.FriendlyExceptions
ASP.NET Core Filter and Middleware to catch exceptions and translate them into nice HTTP responses
Stars: ✭ 17 (+0%)
Mutual labels:  exception-handling
Stacktracey
Parses call stacks. Reads sources. Clean & filtered output. Sourcemaps. Node & browsers.
Stars: ✭ 115 (+576.47%)
Mutual labels:  exception-handling
react-error-guard
⚛️An overlay for displaying stack frames based on create-react-app/packages/react-error-overlay
Stars: ✭ 18 (+5.88%)
Mutual labels:  exception-handling
catchr
catchr: Flexible, useful tools for dealing with conditions in R, for new users and veterans
Stars: ✭ 17 (+0%)
Mutual labels:  exception-handling
laravel-email-exceptions
Email Exceptions package for Laravel 5.x
Stars: ✭ 33 (+94.12%)
Mutual labels:  exception-handling
Dsl.scala
A framework to create embedded Domain-Specific Languages in Scala
Stars: ✭ 220 (+1194.12%)
Mutual labels:  exception-handling
snq
A utility function to avoid type errors when traversing over arrays and object properties.
Stars: ✭ 30 (+76.47%)
Mutual labels:  exception-handling
ignition-stackoverflow
An Ignition tab that fetches StackOverflow questions and provides a searchbar.
Stars: ✭ 74 (+335.29%)
Mutual labels:  exception-handling
Object Oriented Programming Using Python
Python is a multi-paradigm programming language. Meaning, it supports different programming approach. One of the popular approach to solve a programming problem is by creating objects. This is known as Object-Oriented Programming (OOP).
Stars: ✭ 183 (+976.47%)
Mutual labels:  exception-handling
DuckOS
Such OS; Very Duck!
Stars: ✭ 16 (-5.88%)
Mutual labels:  exception-handling
Catch Exception
Stars: ✭ 137 (+705.88%)
Mutual labels:  exception-handling
Coderr.Client
Core client library for Coderr
Stars: ✭ 23 (+35.29%)
Mutual labels:  exception-handling
try-let
Better exception handling for Clojure let expressions
Stars: ✭ 17 (+0%)
Mutual labels:  exception-handling
mwe-cpp-exception
Minimum working example of proper C++11 exception handling
Stars: ✭ 20 (+17.65%)
Mutual labels:  exception-handling
stack-trace-art
Turning programming exceptions into art
Stars: ✭ 39 (+129.41%)
Mutual labels:  exception-handling

ex

Deprecation notice

No longer in developement, if you want the same ideas with way better implementation, head to exoscale/ex

cljdoc badge

An exception library, drop in replacement for try/catch/finally, that adds support for ex-info/ex-data with a custom (clojure) hierarchy that allows to express exceptions relations.

So we have qbits.ex/try+, which supports vanilla catch/finally clauses. If you specify a catch-data clause with a keyword as first argument things get interesting. We assume you always put a :type key in the ex-info you want to use with this, and will match its value to the value of the key in the catch-data clause.

Essentially catch-data takes this form:

(catch-data :something m
   ;; where m is a binding to the ex-data (you can destructure at that level as well)
   )

So you can do things like that.

(require '[qbits.ex :as ex])

(ex/try+

  (throw (ex-info "Argh" {:type ::bar :foo "a foo"}))

  (catch-data ::foo data
    (prn :got-ex-data data))

  (catch-data ::bar {:as data :keys [foo]}
    ;; in that case it would hit this one
    (prn :got-ex-data-again foo))

  (catch ExceptionInfo e
   ;; this would match an ex-info that didn't get a hit with catch-ex-info)

  (catch Exception e (prn :boring))

  (finally (prn :boring-too)))

But there's a twist.

I thought leveraging a clojure hierarchy could make sense in that context too, so you can essentially create exceptions hierachies without having to mess with Java classes directly and in a clojuresque" way.

;; so bar is a foo

(ex/derive ::bar ::foo)

(ex/try+
  (throw (ex-info "I am a bar" {:type ::bar})
  (catch-data ::foo d
    (prn "got a foo with data" d)
    (prn "Original exception instance is " (-> d meta ::ex/exception))))

You can also get the full exception instance via the metadata on the ex-data we extract, it's under the :qbits.ex/exception key.

Some real life examples of usage for this:

  • make some exceptions end-user exposable in http responses via an error middleware in a declarative way .

  • skip sentry logging for some kind of exceptions (or the inverse)

  • make an exception hierachy for our query language type of errors for specialized reporting per "type"

Other than that it's largely inspired by catch-data, the implementation is slightly different, we dont catch Throwable, we instead generate a catch clause on clj ex-info and generate a cond that tries to match ex-data with the :type key using isa? with our hierarchy, which arguably is closer to I would write by hand in that case.

Installation

ex is available on Clojars.

Add this to your dependencies:

Clojars Project

or you can just grab it via deps.edn directly

License

Copyright © 2018 Max Penet

Distributed under the Eclipse Public License, the same as Clojure.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].