Commit 36298687 authored by Andrew Stebenne's avatar Andrew Stebenne
Browse files

Change the command line -preference parameter to throw an exception when given...

Change the command line -preference parameter to throw an exception when given an invalid preference file. Reference ticket #2115.

git-svn-id: http://subversion.wr.usgs.gov/repos/prog/isis3/trunk@6233 41f8697f-d340-4b68-9986-7bafba869bb8
parent e6bba777
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -48,6 +48,13 @@ namespace Isis {
    if(Isis::FileName(file).fileExists()) {
      pvl.read(file);
    }
    else {
      // Throw an exception if the preference file isn't found
      throw IException(IException::User,
                       QString("The preference file %1 was not found or does not exist").arg(file),
                       _FILEINFO_);
    }


    // Override parameters each time load is called
    for(int i = 0; i < pvl.groups(); i++) {
+4 −0
Original line number Diff line number Diff line
@@ -69,6 +69,10 @@ namespace Isis {
   *                           limit in the Qt global thread pool.
   *   @history 2013-03-27 Jeannie Backer - Added Near mission to DataDirectory
   *                           group to TestPreferences file. References #1248.
   *   @history 2015-05-27 Andrew Stebenne - Backwards Compatibility Issue:
   *                           Preference now throws an exception when Preference.Load()
   *                           is called on a nonexistent preference file. This may cause issues
   *                           for anyone who has been using a nonexistent preference file.
   */
  class Preference : public Pvl {

+1 −0
Original line number Diff line number Diff line
@@ -10,3 +10,4 @@ End_Group


Value of Vegetable is : Potatoe
**USER ERROR** The preference file dummyPrefs was not found or does not exist.
+10 −0
Original line number Diff line number Diff line
@@ -56,5 +56,15 @@ int main() {
    error.print();
  }

  // Now test without a preference file to see if the expected exception is thrown
  try {
    Isis::Preference::Preferences(true);
    Isis::Preference::Preferences(true).Load("dummyPrefs");
  }
  // Expect to see: "The preference file dummyPrefs was not found or does not exist."
  catch(Isis::IException &error) {
    error.print();
  }

  return 0;
}