Protect against null error object

In certain situations, library fails to parse the recurly error message (example below). This will lead to a null RecurlyAPIError object (which is fine) and an NPE in the RecurlyAPIException ctr - which is not.
This fix just guards against this, so that we have a reasonable RecurlyAPIException, and not an NPE.

Example:
RecurlyClient@832 inits recurlyError with null. An exception in line 834 would lead to an NPE in line 838.
right

On Thu, Oct 23, 2014 at 9:09 PM, maxkremer <notifications@github.com> wrote:

> In src/main/java/com/ning/billing/recurly/RecurlyAPIException.java:
>
> > @@ -23,7 +23,7 @@
> >      private final RecurlyAPIError recurlyError;
> >
> >      public RecurlyAPIException(final RecurlyAPIError recurlyError) {
> > -        super(recurlyError.toString());
> > +        super(recurlyError.toString()==null? "Unspecified API Error" : recurlyError.toString());
>
> 'recurlyError.toString()' will still throw an NPE. You need
> 'super(recurlyError ==null? "Unspecified API Error" :
> recurlyError.toString());'
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/killbilling/recurly-java-library/pull/56/files#r19295886>
> .
>



-- 

*Omri Spector*

Software Development & Consulting

Phone: +972-50-2190755 | Mail: omri.spector@gmail.com |
http://il.linkedin.com/in/ospector