26 Sep 2013, 16:03
Generic-user-small

craig ferry (12 posts)

I had a problem in the database access chapter which I have now resolved. However, if any one could shed any light on how I could have debugged the problem more quickly I would be very appreciative.

I made a typo for the occupation field in the employee template def. As a result the occupation field was returning nil in the vector. When I tried to create the pdf using this data the only error I got was:

NullPointerException   clojure.core/name (core.clj:1505)

This made it very difficult to work out where my code was wrong. Up until now clojure error messages have been very informative and pointed me in the right direction to debug. Is there anything I could have done when using the clj-pdf library that would have helped me trace the problem more quickly?

27 Sep 2013, 01:03
Profile_pic_pragsmall

Dmitri Sotnikov (35 posts)

Unfortunately, it’s a case of bad error reporting in clj-pdf. The table cell didn’t handle nil values correctly and barfed with a very unhelpful exception. Good news is that I updated the library to handle nils intelligently in that case.

The quality of errors will vary from library to library. In cases where the error is not obvious, it’s often easiest to to see where a relevant namespace shows up in the stacktrace and check what it’s doing.

In this case the last namespace before the core ones is clj-pdf.core in the table-cell function. Since we’re getting a null pointer we know that it got passed a nil value it gives us a lead that we’re probably missing one of the keys.

Another option is to use a debugger to trace the problem. The Eclipse CCW plugin lets you breakpoint and step through the code to see where it breaks. The IDE appendix takes your through the steps of setting it up.

Hope that helps,

Dmitri

27 Sep 2013, 11:57
Generic-user-small

craig ferry (12 posts)

Thanks for the pointers.

I will recreate the error and follow through your advice to become more familiar with this.

  You must be logged in to comment