Fix name of imported cbz, fix library check
[nikiroo-utils.git] / src / be / nikiroo / fanfix / Instance.java
index c48b119052ff24f5c184ccf89c79edf8dd78961c..97e9868b8858ad2475b96cb7f51df3ae50d04683 100644 (file)
@@ -82,12 +82,6 @@ public class Instance {
 
                uiconfig = new UiConfigBundle();
                trans = new StringIdBundle(getLang());
-               try {
-                       lib = new LocalLibrary(getFile(Config.LIBRARY_DIR));
-               } catch (Exception e) {
-                       syserr(new IOException("Cannot create library for directory: "
-                                       + getFile(Config.LIBRARY_DIR), e));
-               }
 
                boolean debug = Instance.getConfig()
                                .getBoolean(Config.DEBUG_ERR, false);
@@ -110,6 +104,13 @@ public class Instance {
                tracer.setShowErrorDetails(debug);
                tracer.setShowTraces(trace);
 
+               try {
+                       lib = new LocalLibrary(getFile(Config.LIBRARY_DIR));
+               } catch (Exception e) {
+                       syserr(new IOException("Cannot create library for directory: "
+                                       + getFile(Config.LIBRARY_DIR), e));
+               }
+
                // Could have used: System.getProperty("java.io.tmpdir")
                if (tmp == null) {
                        tmp = new File(configDir, "tmp");
@@ -200,6 +201,10 @@ public class Instance {
         * @return the {@link LocalLibrary}
         */
        public static BasicLibrary getLibrary() {
+               if (lib == null) {
+                       throw new NullPointerException("We don't have a library to return");
+               }
+
                return lib;
        }