44import java .io .IOException ;
55import java .io .InputStream ;
66import java .io .InputStreamReader ;
7+ import static java .lang .String .format ;
78
89import org .json .simple .JSONObject ;
910import org .json .simple .parser .JSONParser ;
@@ -167,8 +168,11 @@ public void setAuthCallBackUrl(String authCallbackUrl) {
167168 AUTH_CALLBACK_URL = authCallbackUrl ;
168169 }
169170
170- public void load () {
171+ private void load () {
171172 InputStream inputStream = JsonConfig .class .getResourceAsStream ("/" + configFile );
173+ if (inputStream == null ) {
174+ throw new XeroClientException (format ("Config file '%s' could not be opened. Missing file?" , configFile ));
175+ }
172176 InputStreamReader reader = new InputStreamReader (inputStream );
173177
174178 JSONParser parser = new JSONParser ();
@@ -177,11 +181,11 @@ public void load() {
177181 try {
178182 obj = parser .parse (reader );
179183 } catch (FileNotFoundException e ) {
180- e . printStackTrace ( );
184+ throw new XeroClientException ( format ( "Config file '%s' not found" , configFile ), e );
181185 } catch (IOException e ) {
182- e . printStackTrace ( );
186+ throw new XeroClientException ( format ( "IO error reading config file '%s' not found" , configFile ), e );
183187 } catch (ParseException e ) {
184- e . printStackTrace ( );
188+ throw new XeroClientException ( format ( "Parse error reading config file '%s' not found" , configFile ), e );
185189 }
186190 JSONObject jsonObject = (JSONObject ) obj ;
187191
0 commit comments