Improve error messages by using pr-str instead of str when printing objects

Description

Many error messages from ClojureScript include the invalid argument like this:

(throw (js/Error. (str "Doesn't support name: " x)))

If x is nil, then the error message produces is "Doesn't support name: " which is a bit mystifying to debug. If x was wrapped with pr-str then the error message would be the much more understandable: "Doesn't support name: nil".

If there's interest in this, then I can prepare a patch which wraps these kinds of errors with pr-str.

Environment

None

Attachments

2
  • 20 Apr 2019, 08:29 PM
  • 15 Mar 2018, 07:33 PM

Activity

Show:

Mike Fikes March 31, 2020 at 11:44 PM

0001-CLJS-1908-Wrap-vars-in-throw-message-with-pr-str-2.patch conflicts with master

Mike Fikes May 12, 2019 at 2:23 AM

0001-CLJS-1908-Wrap-vars-in-throw-message-with-pr-str-2.patch added to Patch Tender Info

Mike Fikes April 26, 2019 at 1:33 AM

0001-CLJS-1908-Wrap-vars-in-throw-message-with-pr-str-2.patch passes CI and Canary Check Mark

Mike Fikes April 25, 2019 at 2:53 AM

0001-CLJS-1908-Wrap-vars-in-throw-message-with-pr-str-2.patch LGTM

Erik Assum April 20, 2019 at 8:30 PM

0001-CLJS-1908-Wrap-vars-in-throw-message-with-pr-str-2.patch updated, should apply

Details

Assignee

Reporter

Labels

Patch

Code

Priority

Created January 27, 2017 at 12:54 AM
Updated March 31, 2020 at 11:44 PM

Flag notifications