Skip to content

Pre-conditions should not be used when IllegalArgumentException is appropriate #85

@jakepic1

Description

@jakepic1

As Clojure is currently implemented, a failing pre- or post-condition throws an AssertionError, as opposed to an Exception. Errors are subclasses of Throwable but not of Exception: http://docs.oracle.com/javase/7/docs/api/java/lang/Error.html. Per the javadoc on Error: "An Error is a subclass of Throwable that indicates serious problems that a reasonable application should not try to catch. Most such errors are abnormal conditions."

Things like ensuring an input is a positive number, ensuring certain keys are in a map, etc. are things that should typically be Exceptions.

http://programmers.stackexchange.com/questions/137158/is-it-better-to-use-assert-or-illegalargumentexception-for-required-method-param

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions