Liking cljdoc? Tell your friends :D

com.noahbogart.sinker

Catch exceptions hook, line, and sinker.

fuck ai forever.

sinker is an attempt to write the smallest possible try/catch extension. it should be a seamless drop-in for existing code, and the extensions should be simple and obvious.

try+, the single public var, analyzes each form and outputs the associated code to handle them. it merges similar/overlapping catch clauses, uses cond or case where appropriate, and does its best to not waste cycles.

Catch exceptions hook, line, and sinker.

fuck ai forever.

sinker is an attempt to write the smallest possible try/catch extension. it should be a seamless drop-in for existing code, and the extensions should be simple and obvious.

`try+`, the single public var, analyzes each form and outputs the associated code to handle them. it merges similar/overlapping `catch` clauses, uses `cond` or `case` where appropriate, and does its best to not waste cycles.
raw docstring

emit-catchesclj/s

(emit-catches t ex-info? data catch-clauses)

for each catch type, emit the cond+ branches that match the exception and then execute the catch body.

for a keyword or fn match, attach the exception as ::exception metadata

for each catch type, emit the cond+ branches that match the exception and then execute the catch body.

for a keyword or fn match, attach the exception as ::exception metadata
sourceraw docstring

emit-exprsclj/s

(emit-exprs exprs)

Instead of emitting the body directly, wrap expr in a let and do to prevent unwanted recur targets or any catch or finally clauses that we didn't catch otherwise

Instead of emitting the body directly, wrap `expr` in a `let` and `do` to prevent unwanted recur targets or any `catch` or `finally` clauses that we didn't catch otherwise
sourceraw docstring

emit-finallysclj/s

(emit-finallys finally-clauses)

don't do anything for finallys, they're perfect just the way they are

don't do anything for finallys, they're perfect just the way they are
sourceraw docstring

index-ofclj/s

(index-of coll pred)

returns idx or nil if pred doesn't match

returns idx or nil if pred doesn't match
sourceraw docstring

parse-catch-clauseclj/s

(parse-catch-clause clause)

Given a (catch ...) clause, what kind of catch should we generate?

  • :keyword => dispatch on type
  • 'symbol => dispatch on class (using instance?)
  • #'var => dispatch as a predicate
  • otherwise => throw

return a map of {:pred :id :body :type} where :type is one of :catch/default, :catch/type, :catch/raw, :catch/class, :catch/fn

Given a `(catch ...)` clause, what kind of catch should we generate?

* `:keyword` => dispatch on type
* `'symbol` => dispatch on class (using `instance?`)
* `#'var` => dispatch as a predicate
* otherwise => throw

return a map of `{:pred :id :body :type}` where `:type` is one of `:catch/default`, `:catch/type`, `:catch/raw`, `:catch/class`, `:catch/fn`
sourceraw docstring

parse-clauseclj/s

(parse-clause expr)

convert each form to the appropriate IR node

convert each form to the appropriate IR node
sourceraw docstring

parse-exprclj/s

(parse-expr expr)

IR node for anything before a (catch) or (finally)

IR node for anything before a `(catch)` or `(finally)`
sourceraw docstring

parse-finally-clauseclj/s

(parse-finally-clause expr)

IR node for (finally ...)

IR node for (finally ...)
sourceraw docstring

split-clausesclj/s

(split-clauses clauses)

We don't want to partition-by, we want to cleanly split into 3 chunks: expressions, catches, finallys. If expressions end up in the later ones, or finallys end up in the earlier ones, too bad. We'll rely on Clojure's built-in try/catch analyzer throw in that case.

We don't want to partition-by, we want to cleanly split into 3 chunks: expressions, catches, finallys. If expressions end up in the later ones, or finallys end up in the earlier ones, too bad. We'll rely on Clojure's built-in try/catch analyzer throw in that case.
sourceraw docstring

split-vecclj/s

(split-vec vec idx)

Returns a vector of the given vec split at idx. If idx is nil, returns [vec nil].

Returns a vector of the given vec split at `idx`. If `idx` is `nil`, returns [vec nil].
sourceraw docstring

try+clj/smacro

(try+ & body)
source

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close