An open API service indexing awesome lists of open source software.

https://github.com/nomicflux/danger-mouse

Error Handling in Clojure
https://github.com/nomicflux/danger-mouse

clojure error-handling

Last synced: 5 days ago
JSON representation

Error Handling in Clojure

Awesome Lists containing this project

README

          

README.html

body { box-sizing: border-box; max-width: 740px; width: 100%; margin: 40px auto; padding: 0 10px; } document.addEventListener('DOMContentLoaded', () => { document.body.classList.add('markdown-body'); document.querySelectorAll('pre[lang] > code').forEach((code) => { code.classList.add(code.parentElement.lang); }); document.querySelectorAll('pre > code').forEach((code) => { hljs.highlightBlock(code); }); });

danger-mouse


Error handling for processing pipelines of information in Clojure.


Usage


Capturing errors for reporting while continuing to process data:


(danger-mouse.catch-errors/catch-errors-> [1 2 3]

(map inc)
(map #(if (even? %) % (throw (Exception. (str %)))))
(map #(* % 10)))

> {:result [20 40]
:errors [{:error-msg "3"
:input 2
:error ....}]}


Using try-catch as a function, then apply different functions over errors and successes:


(->> (danger-mouse.macros/try-catch (throw (Exception. "Oops")))

(danger-mouse.utils/resolve ex-message str))

> "Oops"

(->> (danger-mouse.macros/try-catch 1)
(danger-mouse.utils/resolve ex-message str))

> "1"


License


MIT License


Copyright © 2021-2023 Michael Anderson


Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:


The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.


THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.