This repository has been archived by the owner on Jan 28, 2019. It is now read-only.
forked from clojure/clojure
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add meaningful messages to common RT errors
This patch wraps many of the collections functions in clojure.lang.RT with try/catch blocks designed to provide clearer error reporting when the user provides them with inappropriate arguments. Previously raw ClassCastExceptions from cast sites could be propagated to the user. While precise, these errors are unclear because they don't state what expectation was violated, Eg. object on which a cast needed to be sequable or a map or such. This leaves users, especially new users, exposed to the raw implementation of Clojure in terms of Java interfaces and not stated Clojure abstractions such as maps and seqs. Ex. ```clojure (assoc (Object.) :foo :bar) ;; IllegalArgumentException assoc needs an associative, got java.lang.Object clojure.lang.RT.assoc (RT.java:820) ``` This does technically make this patch a breaking change, since it changes the exception thrown by many type missmatches from a ClassCastException to a more user meaningful IllegalArgumentException.
- Loading branch information
Showing
2 changed files
with
107 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters