#include "OptionsFilename.h"
#include <stdexcept>

namespace
{
std::string filename;
bool filenameSet = false;
}

const std::string& getOptionsFilename()
{
    return filename;
}

void setOptionsFilename(const std::string & optionsFilename)
{
    if (filenameSet)
    {
        throw std::runtime_error("Options filename already set");
    }
    else
    {
        filename = optionsFilename;
        filenameSet = true;
    }
}

#include "OptionsFilename.h"
#include <stdexcept>

namespace
{
std::string filename;
bool filenameSet = false;
}

const std::string& getOptionsFilename()
{
    return filename;
}

void setOptionsFilename(const std::string & optionsFilename)
{
    if (filenameSet)
        throw std::runtime_error("Options filename already set");
    filename = optionsFilename;
    filenameSet = true;
}

--- 
+++ 
@@ -15,7 +15,12 @@
 void setOptionsFilename(const std::string & optionsFilename)
 {
     if (filenameSet)
+    {
         throw std::runtime_error("Options filename already set");
-    filename = optionsFilename;
-    filenameSet = true;
+    }
+    else
+    {
+        filename = optionsFilename;
+        filenameSet = true;
+    }
 }
Use a full if/else block around an exception throw
