diff options
Diffstat (limited to 'indra')
30 files changed, 234 insertions, 143 deletions
| diff --git a/indra/llcommon/CMakeLists.txt b/indra/llcommon/CMakeLists.txt index 907dbab8f8..44f45144e5 100644 --- a/indra/llcommon/CMakeLists.txt +++ b/indra/llcommon/CMakeLists.txt @@ -157,6 +157,7 @@ set(llcommon_HEADER_FILES      lleventfilter.h      llevents.h      lleventemitter.h +    llexception.h      llfasttimer.h      llfile.h      llfindlocale.h diff --git a/indra/llcommon/lldependencies.cpp b/indra/llcommon/lldependencies.cpp index 0e72c175cb..87a699ff14 100644 --- a/indra/llcommon/lldependencies.cpp +++ b/indra/llcommon/lldependencies.cpp @@ -39,6 +39,7 @@  #include <boost/graph/adjacency_list.hpp>  #include <boost/graph/topological_sort.hpp>  #include <boost/graph/exception.hpp> +#include <boost/throw_exception.hpp>  // other Linden headers  LLDependenciesBase::VertexList LLDependenciesBase::topo_sort(int vertices, const EdgeList& edges) const @@ -76,7 +77,7 @@ LLDependenciesBase::VertexList LLDependenciesBase::topo_sort(int vertices, const          // Omit independent nodes: display only those that might contribute to          // the cycle.          describe(out, false); -        throw Cycle(out.str()); +        BOOST_THROW_EXCEPTION(Cycle(out.str()));      }      // A peculiarity of boost::topological_sort() is that it emits results in      // REVERSE topological order: to get the result you want, you must diff --git a/indra/llcommon/lldependencies.h b/indra/llcommon/lldependencies.h index e0294e271b..125bd6a835 100644 --- a/indra/llcommon/lldependencies.h +++ b/indra/llcommon/lldependencies.h @@ -34,13 +34,13 @@  #include <vector>  #include <set>  #include <map> -#include <stdexcept>  #include <iosfwd>  #include <boost/iterator/transform_iterator.hpp>  #include <boost/iterator/indirect_iterator.hpp>  #include <boost/range/iterator_range.hpp>  #include <boost/function.hpp>  #include <boost/bind.hpp> +#include "llexception.h"  /*****************************************************************************  *   Utilities @@ -106,9 +106,9 @@ public:      /**       * Exception thrown by sort() if there's a cycle       */ -    struct Cycle: public std::runtime_error +    struct Cycle: public LLException      { -        Cycle(const std::string& what): std::runtime_error(what) {} +        Cycle(const std::string& what): LLException(what) {}      };      /** diff --git a/indra/llcommon/lleventcoro.cpp b/indra/llcommon/lleventcoro.cpp index 2d5f964deb..f444530a17 100644 --- a/indra/llcommon/lleventcoro.cpp +++ b/indra/llcommon/lleventcoro.cpp @@ -34,6 +34,7 @@  #include <map>  // std headers  // external library headers +#include <boost/throw_exception.hpp>  // other Linden headers  #include "llsdserialize.h"  #include "llerror.h" @@ -351,7 +352,7 @@ LLSD errorException(const LLEventWithID& result, const std::string& desc)      // returning it, deliver it via exception.      if (result.second)      { -        throw LLErrorEvent(desc, result.first); +        BOOST_THROW_EXCEPTION(LLErrorEvent(desc, result.first));      }      // That way, our caller knows a simple return must be from the reply      // pump (pump 0). diff --git a/indra/llcommon/lleventcoro.h b/indra/llcommon/lleventcoro.h index 87926c692d..84827aab4a 100644 --- a/indra/llcommon/lleventcoro.h +++ b/indra/llcommon/lleventcoro.h @@ -31,10 +31,10 @@  #include <boost/optional.hpp>  #include <string> -#include <stdexcept>  #include <utility>                  // std::pair  #include "llevents.h"  #include "llerror.h" +#include "llexception.h"  /**   * Like LLListenerOrPumpName, this is a class intended for parameter lists: @@ -234,11 +234,11 @@ LLSD errorException(const LLEventWithID& result, const std::string& desc);   * because it's not an error in event processing: rather, this exception   * announces an event that bears error information (for some other API).   */ -class LL_COMMON_API LLErrorEvent: public std::runtime_error +class LL_COMMON_API LLErrorEvent: public LLException  {  public:      LLErrorEvent(const std::string& what, const LLSD& data): -        std::runtime_error(what), +        LLException(what),          mData(data)      {}      virtual ~LLErrorEvent() throw() {} diff --git a/indra/llcommon/llevents.cpp b/indra/llcommon/llevents.cpp index 645c29d770..50919edb8e 100644 --- a/indra/llcommon/llevents.cpp +++ b/indra/llcommon/llevents.cpp @@ -45,6 +45,7 @@  #include <cctype>  // external library headers  #include <boost/range/iterator_range.hpp> +#include <boost/throw_exception.hpp>  #if LL_WINDOWS  #pragma warning (push)  #pragma warning (disable : 4701) // compiler thinks might use uninitialized var, but no @@ -174,7 +175,7 @@ std::string LLEventPumps::registerNew(const LLEventPump& pump, const std::string      // Unless we're permitted to tweak it, that's Bad.      if (! tweak)      { -        throw LLEventPump::DupPumpName(std::string("Duplicate LLEventPump name '") + name + "'"); +        BOOST_THROW_EXCEPTION(LLEventPump::DupPumpName(std::string("Duplicate LLEventPump name '") + name + "'"));      }      // The passed name isn't unique, but we're permitted to tweak it. Find the      // first decimal-integer suffix not already taken. The insert() attempt @@ -326,8 +327,9 @@ LLBoundListener LLEventPump::listen_impl(const std::string& name, const LLEventL      // is only when the existing connection object is still connected.      if (found != mConnections.end() && found->second.connected())      { -        throw DupListenerName(std::string("Attempt to register duplicate listener name '") + name + -                              "' on " + typeid(*this).name() + " '" + getName() + "'"); +        BOOST_THROW_EXCEPTION( +            DupListenerName(std::string("Attempt to register duplicate listener name '") + name + +                            "' on " + typeid(*this).name() + " '" + getName() + "'"));      }      // Okay, name is unique, try to reconcile its dependencies. Specify a new      // "node" value that we never use for an mSignal placement; we'll fix it @@ -353,8 +355,9 @@ LLBoundListener LLEventPump::listen_impl(const std::string& name, const LLEventL          // unsortable. If we leave the new node in mDeps, it will continue          // to screw up all future attempts to sort()! Pull it out.          mDeps.remove(name); -        throw Cycle(std::string("New listener '") + name + "' on " + typeid(*this).name() + -                    " '" + getName() + "' would cause cycle: " + e.what()); +        BOOST_THROW_EXCEPTION( +            Cycle(std::string("New listener '") + name + "' on " + typeid(*this).name() + +                  " '" + getName() + "' would cause cycle: " + e.what()));      }      // Walk the list to verify that we haven't changed the order.      float previous = 0.0, myprev = 0.0; @@ -418,7 +421,7 @@ LLBoundListener LLEventPump::listen_impl(const std::string& name, const LLEventL              // NOW remove the offending listener node.              mDeps.remove(name);              // Having constructed a description of the order change, inform caller. -            throw OrderChange(out.str()); +            BOOST_THROW_EXCEPTION(OrderChange(out.str()));          }          // This node becomes the previous one.          previous = dmi->second; @@ -608,7 +611,7 @@ bool LLListenerOrPumpName::operator()(const LLSD& event) const  {      if (! mListener)      { -        throw Empty("attempting to call uninitialized"); +        BOOST_THROW_EXCEPTION(Empty("attempting to call uninitialized"));      }      return (*mListener)(event);  } diff --git a/indra/llcommon/llevents.h b/indra/llcommon/llevents.h index ba4fcd766e..8ff337911d 100644 --- a/indra/llcommon/llevents.h +++ b/indra/llcommon/llevents.h @@ -37,7 +37,6 @@  #include <set>  #include <vector>  #include <deque> -#include <stdexcept>  #if LL_WINDOWS  	#pragma warning (push)  	#pragma warning (disable : 4263) // boost::signals2::expired_slot::what() has const mismatch @@ -62,6 +61,7 @@  #include "llsingleton.h"  #include "lldependencies.h"  #include "llstl.h" +#include "llexception.h"  /*==========================================================================*|  // override this to allow binding free functions with more parameters @@ -188,10 +188,10 @@ public:      bool operator()(const LLSD& event) const;      /// exception if you try to call when empty -    struct Empty: public std::runtime_error +    struct Empty: public LLException      {          Empty(const std::string& what): -            std::runtime_error(std::string("LLListenerOrPumpName::Empty: ") + what) {} +            LLException(std::string("LLListenerOrPumpName::Empty: ") + what) {}      };  private: @@ -371,10 +371,10 @@ public:       * you didn't pass <tt>tweak=true</tt> to permit it to generate a unique       * variant.       */ -    struct DupPumpName: public std::runtime_error +    struct DupPumpName: public LLException      {          DupPumpName(const std::string& what): -            std::runtime_error(std::string("DupPumpName: ") + what) {} +            LLException(std::string("DupPumpName: ") + what) {}      };      /** @@ -399,9 +399,9 @@ public:      /// group exceptions thrown by listen(). We use exceptions because these      /// particular errors are likely to be coding errors, found and fixed by      /// the developer even before preliminary checkin. -    struct ListenError: public std::runtime_error +    struct ListenError: public LLException      { -        ListenError(const std::string& what): std::runtime_error(what) {} +        ListenError(const std::string& what): LLException(what) {}      };      /**       * exception thrown by listen(). You are attempting to register a diff --git a/indra/llcommon/llexception.h b/indra/llcommon/llexception.h new file mode 100644 index 0000000000..3ac2f4762f --- /dev/null +++ b/indra/llcommon/llexception.h @@ -0,0 +1,63 @@ +/** + * @file   llexception.h + * @author Nat Goodspeed + * @date   2016-06-29 + * @brief  Types needed for generic exception handling + *  + * $LicenseInfo:firstyear=2016&license=viewerlgpl$ + * Copyright (c) 2016, Linden Research, Inc. + * $/LicenseInfo$ + */ + +#if ! defined(LL_LLEXCEPTION_H) +#define LL_LLEXCEPTION_H + +#include <stdexcept> +#include <boost/exception/exception.hpp> + +/** + * LLException is intended as the common base class from which all + * viewer-specific exceptions are derived. It is itself a subclass of + * boost::exception; use catch (const boost::exception& e) clause to log the + * string from boost::diagnostic_information(e). + * + * Since it is also derived from std::exception, a generic catch (const + * std::exception&) should also work, though what() is unlikely to be as + * informative as boost::diagnostic_information(). + * + * Please use BOOST_THROW_EXCEPTION() + * http://www.boost.org/doc/libs/release/libs/exception/doc/BOOST_THROW_EXCEPTION.html + * to throw viewer exceptions whenever possible. This enriches the exception's + * diagnostic_information() with the source file, line and containing function + * of the BOOST_THROW_EXCEPTION() macro. + * + * There may be circumstances in which it would be valuable to distinguish an + * exception explicitly thrown by viewer code from an exception thrown by + * (say) a third-party library. Catching (const LLException&) supports such + * usage. However, most of the value of this base class is in the + * diagnostic_information() available via Boost.Exception. + */ +struct LLException: +    public std::runtime_error, +    public boost::exception +{ +    LLException(const std::string& what): +        std::runtime_error(what) +    {} +}; + +/** + * The point of LLContinueError is to distinguish exceptions that need not + * terminate the whole viewer session. In general, an uncaught exception will + * be logged and will crash the viewer. However, though an uncaught exception + * derived from LLContinueError will still be logged, the viewer will attempt + * to continue processing. + */ +struct LLContinueError: public LLException +{ +    LLContinueError(const std::string& what): +        LLException(what) +    {} +}; + +#endif /* ! defined(LL_LLEXCEPTION_H) */ diff --git a/indra/llcommon/llleap.cpp b/indra/llcommon/llleap.cpp index 84d2a12f65..a8bb9bc53a 100644 --- a/indra/llcommon/llleap.cpp +++ b/indra/llcommon/llleap.cpp @@ -21,6 +21,7 @@  #include <boost/bind.hpp>  #include <boost/scoped_ptr.hpp>  #include <boost/tokenizer.hpp> +#include <boost/throw_exception.hpp>  // other Linden headers  #include "llerror.h"  #include "llstring.h" @@ -69,7 +70,7 @@ public:          // Rule out empty vector          if (plugin.empty())          { -            throw Error("no plugin command"); +            BOOST_THROW_EXCEPTION(Error("no plugin command"));          }          // Don't leave desc empty either, but in this case, if we weren't @@ -112,7 +113,7 @@ public:          // If that didn't work, no point in keeping this LLLeap object.          if (! mChild)          { -            throw Error(STRINGIZE("failed to run " << mDesc)); +            BOOST_THROW_EXCEPTION(Error(STRINGIZE("failed to run " << mDesc)));          }          // Okay, launch apparently worked. Change our mDonePump listener. diff --git a/indra/llcommon/llleap.h b/indra/llcommon/llleap.h index e33f25e530..8aac8a64c5 100644 --- a/indra/llcommon/llleap.h +++ b/indra/llcommon/llleap.h @@ -13,9 +13,9 @@  #define LL_LLLEAP_H  #include "llinstancetracker.h" +#include "llexception.h"  #include <string>  #include <vector> -#include <stdexcept>  /**   * LLSD Event API Plugin class. Because instances are managed by @@ -67,9 +67,9 @@ public:       * string(s) passed to create() might come from an external source. This       * way the caller can catch LLLeap::Error and try to recover.       */ -    struct Error: public std::runtime_error +    struct Error: public LLException      { -        Error(const std::string& what): std::runtime_error(what) {} +        Error(const std::string& what): LLException(what) {}      };      virtual ~LLLeap(); diff --git a/indra/llcommon/llprocess.cpp b/indra/llcommon/llprocess.cpp index 44f56daf2d..ca19c94736 100644 --- a/indra/llcommon/llprocess.cpp +++ b/indra/llcommon/llprocess.cpp @@ -39,6 +39,7 @@  #include <boost/bind.hpp>  #include <boost/asio/streambuf.hpp>  #include <boost/asio/buffers_iterator.hpp> +#include <boost/throw_exception.hpp>  #include <iostream>  #include <stdexcept>  #include <limits> @@ -472,9 +473,9 @@ private:  *****************************************************************************/  /// Need an exception to avoid constructing an invalid LLProcess object, but  /// internal use only -struct LLProcessError: public std::runtime_error +struct LLProcessError: public LLException  { -	LLProcessError(const std::string& msg): std::runtime_error(msg) {} +	LLProcessError(const std::string& msg): LLException(msg) {}  };  LLProcessPtr LLProcess::create(const LLSDOrParams& params) @@ -530,8 +531,9 @@ LLProcess::LLProcess(const LLSDOrParams& params):  	if (! params.validateBlock(true))  	{ -		throw LLProcessError(STRINGIZE("not launched: failed parameter validation\n" -									   << LLSDNotationStreamer(params))); +		BOOST_THROW_EXCEPTION( +			LLProcessError(STRINGIZE("not launched: failed parameter validation\n" +									 << LLSDNotationStreamer(params))));  	}  	mPostend = params.postend; @@ -596,10 +598,11 @@ LLProcess::LLProcess(const LLSDOrParams& params):  		}  		else  		{ -			throw LLProcessError(STRINGIZE("For " << params.executable() -										   << ": unsupported FileParam for " << which -										   << ": type='" << fparam.type() -										   << "', name='" << fparam.name() << "'")); +			BOOST_THROW_EXCEPTION( +				LLProcessError(STRINGIZE("For " << params.executable() +										 << ": unsupported FileParam for " << which +										 << ": type='" << fparam.type() +										 << "', name='" << fparam.name() << "'")));  		}  	}  	// By default, pass APR_NO_PIPE for unspecified slots. @@ -678,7 +681,7 @@ LLProcess::LLProcess(const LLSDOrParams& params):  	if (ll_apr_warn_status(apr_proc_create(&mProcess, argv[0], &argv[0], NULL, procattr,  										   gAPRPoolp)))  	{ -		throw LLProcessError(STRINGIZE(params << " failed")); +		BOOST_THROW_EXCEPTION(LLProcessError(STRINGIZE(params << " failed")));  	}  	// arrange to call status_callback() @@ -1063,7 +1066,7 @@ PIPETYPE& LLProcess::getPipe(FILESLOT slot)  	PIPETYPE* wp = getPipePtr<PIPETYPE>(error, slot);  	if (! wp)  	{ -		throw NoPipe(error); +		BOOST_THROW_EXCEPTION(NoPipe(error));  	}  	return *wp;  } diff --git a/indra/llcommon/llprocess.h b/indra/llcommon/llprocess.h index 43ccadc412..bfac4567a5 100644 --- a/indra/llcommon/llprocess.h +++ b/indra/llcommon/llprocess.h @@ -30,13 +30,13 @@  #include "llinitparam.h"  #include "llsdparam.h"  #include "llwin32headerslean.h" +#include "llexception.h"  #include "apr_thread_proc.h"  #include <boost/shared_ptr.hpp>  #include <boost/ptr_container/ptr_vector.hpp>  #include <boost/optional.hpp>  #include <boost/noncopyable.hpp>  #include <iosfwd>                   // std::ostream -#include <stdexcept>  #if LL_WINDOWS  #include "llwin32headerslean.h"	// for HANDLE @@ -479,9 +479,9 @@ public:  	/// Exception thrown by getWritePipe(), getReadPipe() if you didn't ask to  	/// create a pipe at the corresponding FILESLOT. -	struct NoPipe: public std::runtime_error +	struct NoPipe: public LLException  	{ -		NoPipe(const std::string& what): std::runtime_error(what) {} +		NoPipe(const std::string& what): LLException(what) {}  	};  	/** diff --git a/indra/llcommon/llthreadsafequeue.cpp b/indra/llcommon/llthreadsafequeue.cpp index 185f0d63fb..a004618e96 100644 --- a/indra/llcommon/llthreadsafequeue.cpp +++ b/indra/llcommon/llthreadsafequeue.cpp @@ -26,6 +26,7 @@  #include "linden_common.h"  #include <apr_pools.h>  #include <apr_queue.h> +#include <boost/throw_exception.hpp>  #include "llthreadsafequeue.h" @@ -41,13 +42,13 @@ LLThreadSafeQueueImplementation::LLThreadSafeQueueImplementation(apr_pool_t * po  {  	if(mOwnsPool) {  		apr_status_t status = apr_pool_create(&mPool, 0); -		if(status != APR_SUCCESS) throw LLThreadSafeQueueError("failed to allocate pool"); +		if(status != APR_SUCCESS) BOOST_THROW_EXCEPTION(LLThreadSafeQueueError("failed to allocate pool"));  	} else {  		; // No op.  	}  	apr_status_t status = apr_queue_create(&mQueue, capacity, mPool); -	if(status != APR_SUCCESS) throw LLThreadSafeQueueError("failed to allocate queue"); +	if(status != APR_SUCCESS) BOOST_THROW_EXCEPTION(LLThreadSafeQueueError("failed to allocate queue"));  } @@ -68,9 +69,9 @@ void LLThreadSafeQueueImplementation::pushFront(void * element)  	apr_status_t status = apr_queue_push(mQueue, element);  	if(status == APR_EINTR) { -		throw LLThreadSafeQueueInterrupt(); +		BOOST_THROW_EXCEPTION(LLThreadSafeQueueInterrupt());  	} else if(status != APR_SUCCESS) { -		throw LLThreadSafeQueueError("push failed"); +		BOOST_THROW_EXCEPTION(LLThreadSafeQueueError("push failed"));  	} else {  		; // Success.  	} @@ -88,9 +89,9 @@ void * LLThreadSafeQueueImplementation::popBack(void)  	apr_status_t status = apr_queue_pop(mQueue, &element);  	if(status == APR_EINTR) { -		throw LLThreadSafeQueueInterrupt(); +		BOOST_THROW_EXCEPTION(LLThreadSafeQueueInterrupt());  	} else if(status != APR_SUCCESS) { -		throw LLThreadSafeQueueError("pop failed"); +		BOOST_THROW_EXCEPTION(LLThreadSafeQueueError("pop failed"));  	} else {  		return element;  	} diff --git a/indra/llcommon/llthreadsafequeue.h b/indra/llcommon/llthreadsafequeue.h index 58cac38769..45289ef0b4 100644 --- a/indra/llcommon/llthreadsafequeue.h +++ b/indra/llcommon/llthreadsafequeue.h @@ -27,9 +27,8 @@  #ifndef LL_LLTHREADSAFEQUEUE_H  #define LL_LLTHREADSAFEQUEUE_H - +#include "llexception.h"  #include <string> -#include <stdexcept>  struct apr_pool_t; // From apr_pools.h @@ -40,11 +39,11 @@ class LLThreadSafeQueueImplementation; // See below.  // A general queue exception.  //  class LL_COMMON_API LLThreadSafeQueueError: -public std::runtime_error +	public LLException  {  public:  	LLThreadSafeQueueError(std::string const & message): -	std::runtime_error(message) +		LLException(message)  	{  		; // No op.  	} diff --git a/indra/llcommon/lluuid.cpp b/indra/llcommon/lluuid.cpp index e3671047b4..785cf47926 100644 --- a/indra/llcommon/lluuid.cpp +++ b/indra/llcommon/lluuid.cpp @@ -83,7 +83,7 @@ unsigned int decode( char const * fiveChars ) throw( bad_input_data )  unsigned int ret = 0;  for( int ix = 0; ix < 5; ++ix ) {  char * s = strchr( encodeTable, fiveChars[ ix ] ); -if( s == 0 ) throw bad_input_data(); +if( s == 0 ) BOOST_THROW_EXCEPTION(bad_input_data());  ret = ret * 85 + (s-encodeTable);  }  return ret; diff --git a/indra/llcommon/tests/wrapllerrs.h b/indra/llcommon/tests/wrapllerrs.h index 785197ba11..fa16fd6915 100644 --- a/indra/llcommon/tests/wrapllerrs.h +++ b/indra/llcommon/tests/wrapllerrs.h @@ -35,13 +35,14 @@  #include <tut/tut.hpp>  #include "llerrorcontrol.h" +#include "llexception.h"  #include "stringize.h"  #include <boost/bind.hpp>  #include <boost/noncopyable.hpp>  #include <boost/shared_ptr.hpp> +#include <boost/throw_exception.hpp>  #include <list>  #include <string> -#include <stdexcept>  // statically reference the function in test.cpp... it's short, we could  // replicate, but better to reuse @@ -67,9 +68,9 @@ struct WrapLLErrs          LLError::restoreSettings(mPriorErrorSettings);      } -    struct FatalException: public std::runtime_error +    struct FatalException: public LLException      { -        FatalException(const std::string& what): std::runtime_error(what) {} +        FatalException(const std::string& what): LLException(what) {}      };      void operator()(const std::string& message) @@ -78,7 +79,7 @@ struct WrapLLErrs          error = message;          // Also throw an appropriate exception since calling code is likely to          // assume that control won't continue beyond LL_ERRS. -        throw FatalException(message); +        BOOST_THROW_EXCEPTION(FatalException(message));      }      std::string error; diff --git a/indra/llimage/llpngwrapper.cpp b/indra/llimage/llpngwrapper.cpp index 531859cbc9..0b7d4c717f 100644 --- a/indra/llimage/llpngwrapper.cpp +++ b/indra/llimage/llpngwrapper.cpp @@ -31,12 +31,13 @@  #include "llimage.h"  #include "llpngwrapper.h" -#include <stdexcept> +#include "llexception.h" +#include <boost/throw_exception.hpp>  namespace { -struct PngError: public std::runtime_error +struct PngError: public LLException  { -    PngError(png_const_charp msg): std::runtime_error(msg) {} +    PngError(png_const_charp msg): LLException(msg) {}  };  } // anonymous namespace @@ -87,7 +88,7 @@ BOOL LLPngWrapper::isValidPng(U8* src)  // occurs. We throw PngError and let our try/catch block clean up.  void LLPngWrapper::errorHandler(png_structp png_ptr, png_const_charp msg)  { -	throw PngError(msg); +	BOOST_THROW_EXCEPTION(PngError(msg));  }  // Called by the libpng library when reading (decoding) the PNG file. We @@ -137,7 +138,7 @@ BOOL LLPngWrapper::readPng(U8* src, S32 dataSize, LLImageRaw* rawImage, ImageInf  			this, &errorHandler, NULL);  		if (mReadPngPtr == NULL)  		{ -			throw PngError("Problem creating png read structure"); +			BOOST_THROW_EXCEPTION(PngError("Problem creating png read structure"));  		}  		// Allocate/initialize the memory for image information. @@ -296,14 +297,14 @@ BOOL LLPngWrapper::writePng(const LLImageRaw* rawImage, U8* dest)  		if (mColorType == -1)  		{ -			throw PngError("Unsupported image: unexpected number of channels"); +			BOOST_THROW_EXCEPTION(PngError("Unsupported image: unexpected number of channels"));  		}  		mWritePngPtr = png_create_write_struct(PNG_LIBPNG_VER_STRING,  			NULL, &errorHandler, NULL);  		if (!mWritePngPtr)  		{ -			throw PngError("Problem creating png write structure"); +			BOOST_THROW_EXCEPTION(PngError("Problem creating png write structure"));  		}  		mWriteInfoPtr = png_create_info_struct(mWritePngPtr); diff --git a/indra/llkdu/llimagej2ckdu.cpp b/indra/llkdu/llimagej2ckdu.cpp index 2a5b24fbc1..fa58931407 100644 --- a/indra/llkdu/llimagej2ckdu.cpp +++ b/indra/llkdu/llimagej2ckdu.cpp @@ -34,12 +34,13 @@  #include "kdu_block_coding.h" -#include <stdexcept> +#include "llexception.h" +#include <boost/throw_exception.hpp>  namespace { -struct KDUError: public std::runtime_error +struct KDUError: public LLException  { -    KDUError(const std::string& msg): std::runtime_error(msg) {} +    KDUError(const std::string& msg): LLException(msg) {}  };  } // anonymous namespace @@ -180,7 +181,7 @@ void LLKDUMessageError::flush(bool end_of_message)  {  	if (end_of_message)   	{ -		throw KDUError("LLKDUMessageError::flush()"); +		BOOST_THROW_EXCEPTION(KDUError("LLKDUMessageError::flush()"));  	}  } diff --git a/indra/llmessage/llhttpnode.cpp b/indra/llmessage/llhttpnode.cpp index 08688ca48b..48ce258ba2 100644 --- a/indra/llmessage/llhttpnode.cpp +++ b/indra/llmessage/llhttpnode.cpp @@ -31,7 +31,8 @@  #include "llstl.h"  #include "llhttpconstants.h" -#include <stdexcept> +#include "llexception.h" +#include <boost/throw_exception.hpp>  const std::string CONTEXT_HEADERS("headers");  const std::string CONTEXT_PATH("path"); @@ -93,28 +94,28 @@ LLHTTPNode::~LLHTTPNode()  namespace { -	struct NotImplemented: public std::runtime_error +	struct NotImplemented: public LLException  	{ -		NotImplemented(): std::runtime_error("LLHTTPNode::NotImplemented") {} +		NotImplemented(): LLException("LLHTTPNode::NotImplemented") {}  	};  }  // virtual  LLSD LLHTTPNode::simpleGet() const  { -	throw NotImplemented(); +	BOOST_THROW_EXCEPTION(NotImplemented());  }  // virtual  LLSD LLHTTPNode::simplePut(const LLSD& input) const  { -	throw NotImplemented(); +	BOOST_THROW_EXCEPTION(NotImplemented());  }  // virtual  LLSD LLHTTPNode::simplePost(const LLSD& input) const  { -	throw NotImplemented(); +	BOOST_THROW_EXCEPTION(NotImplemented());  } @@ -174,7 +175,7 @@ void LLHTTPNode::del(LLHTTPNode::ResponsePtr response, const LLSD& context) cons  // virtual  LLSD LLHTTPNode::simpleDel(const LLSD&) const  { -	throw NotImplemented(); +	BOOST_THROW_EXCEPTION(NotImplemented());  }  // virtual diff --git a/indra/llmessage/tests/commtest.h b/indra/llmessage/tests/commtest.h index 0d149b5258..5dff56b44f 100644 --- a/indra/llmessage/tests/commtest.h +++ b/indra/llmessage/tests/commtest.h @@ -33,15 +33,16 @@  #include "llevents.h"  #include "llsd.h"  #include "llhost.h" +#include "llexception.h"  #include "stringize.h"  #include <map>  #include <string> -#include <stdexcept>  #include <boost/lexical_cast.hpp> +#include <boost/throw_exception.hpp> -struct CommtestError: public std::runtime_error +struct CommtestError: public LLException  { -    CommtestError(const std::string& what): std::runtime_error(what) {} +    CommtestError(const std::string& what): LLException(what) {}  };  static bool query_verbose() @@ -68,7 +69,7 @@ static int query_port(const std::string& var)      const char* cport = getenv(var.c_str());      if (! cport)      { -        throw CommtestError(STRINGIZE("missing environment variable" << var)); +        BOOST_THROW_EXCEPTION(CommtestError(STRINGIZE("missing environment variable" << var)));      }      // This will throw, too, if the value of PORT isn't numeric.      int port(boost::lexical_cast<int>(cport)); diff --git a/indra/llmessage/tests/networkio.h b/indra/llmessage/tests/networkio.h index 2aff90ca1e..6aaecf9bac 100644 --- a/indra/llmessage/tests/networkio.h +++ b/indra/llmessage/tests/networkio.h @@ -34,6 +34,8 @@  #include "llares.h"  #include "llpumpio.h"  #include "llhttpclient.h" +#include "llexception.h" +#include <boost/throw_exception.hpp>  /*****************************************************************************  *   NetworkIO @@ -51,7 +53,7 @@ public:          ll_init_apr();          if (! gAPRPoolp)          { -            throw std::runtime_error("Can't initialize APR"); +            BOOST_THROW_EXCEPTION(LLException("Can't initialize APR"));          }          // Create IO Pump to use for HTTP Requests. @@ -59,7 +61,7 @@ public:          LLHTTPClient::setPump(*mServicePump);          if (ll_init_ares() == NULL || !gAres->isInitialized())          { -            throw std::runtime_error("Can't start DNS resolver"); +            BOOST_THROW_EXCEPTION(LLException("Can't start DNS resolver"));          }          // You can interrupt pump() without waiting the full timeout duration diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index a812a5e518..fdef556589 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -122,6 +122,7 @@  #include "llleap.h"  #include "stringize.h"  #include "llcoros.h" +#include "llexception.h"  #if !LL_LINUX  #include "cef/llceflib.h"  #endif @@ -131,6 +132,7 @@  #include <boost/foreach.hpp>  #include <boost/algorithm/string.hpp>  #include <boost/regex.hpp> +#include <boost/throw_exception.hpp>  #if LL_WINDOWS  #	include <share.h> // For _SH_DENYWR in processMarkerFiles @@ -231,8 +233,6 @@  #include "llcoproceduremanager.h"  #include "llviewereventrecorder.h" -#include <stdexcept> -  // *FIX: These extern globals should be cleaned up.  // The globals either represent state/config/resource-storage of either   // this app, or another 'component' of the viewer. App globals should be  @@ -5513,7 +5513,7 @@ void LLAppViewer::forceErrorInfiniteLoop()  void LLAppViewer::forceErrorSoftwareException()  {     	LL_WARNS() << "Forcing a deliberate exception" << LL_ENDL; -    throw std::runtime_error("User selected Force Software Exception"); +    BOOST_THROW_EXCEPTION(LLException("User selected Force Software Exception"));  }  void LLAppViewer::forceErrorDriverCrash() diff --git a/indra/newview/llcommandlineparser.cpp b/indra/newview/llcommandlineparser.cpp index 1819fc74ee..54f96b8872 100644 --- a/indra/newview/llcommandlineparser.cpp +++ b/indra/newview/llcommandlineparser.cpp @@ -26,6 +26,7 @@  #include "llviewerprecompiledheaders.h"  #include "llcommandlineparser.h" +#include "llexception.h"  // *NOTE: The boost::lexical_cast generates   // the warning C4701(local used with out assignment) in VC7.1. @@ -42,6 +43,7 @@  #include <boost/bind.hpp>  #include <boost/tokenizer.hpp>  #include <boost/assign/list_of.hpp> +#include <boost/throw_exception.hpp>  #if _MSC_VER  #   pragma warning(pop) @@ -98,14 +100,14 @@ namespace      bool gPastLastOption = false;  } -class LLCLPError : public std::logic_error { +class LLCLPError : public LLException {  public: -    LLCLPError(const std::string& what) : std::logic_error(what) {} +    LLCLPError(const std::string& what) : LLException(what) {}  }; -class LLCLPLastOption : public std::logic_error { +class LLCLPLastOption : public LLException {  public: -    LLCLPLastOption(const std::string& what) : std::logic_error(what) {} +    LLCLPLastOption(const std::string& what) : LLException(what) {}  };  class LLCLPValue : public po::value_semantic_codecvt_helper<char>  @@ -202,17 +204,17 @@ protected:      {          if(gPastLastOption)          { -            throw(LLCLPLastOption("Don't parse no more!")); +            BOOST_THROW_EXCEPTION(LLCLPLastOption("Don't parse no more!"));          }          // Error checks. Needed?          if (!value_store.empty() && !is_composing())           { -            throw(LLCLPError("Non composing value with multiple occurences.")); +            BOOST_THROW_EXCEPTION(LLCLPError("Non composing value with multiple occurences."));          }          if (new_tokens.size() < min_tokens() || new_tokens.size() > max_tokens())          { -            throw(LLCLPError("Illegal number of tokens specified.")); +            BOOST_THROW_EXCEPTION(LLCLPError("Illegal number of tokens specified."));          }          if(value_store.empty()) @@ -466,7 +468,7 @@ onevalue(const std::string& option,      {          // What does it mean when the user specifies a command-line switch          // that requires a value, but omits the value? Complain. -        throw LLCLPError(STRINGIZE("No value specified for --" << option << "!")); +        BOOST_THROW_EXCEPTION(LLCLPError(STRINGIZE("No value specified for --" << option << "!")));      }      else if (value.size() > 1)      { @@ -484,9 +486,10 @@ void badvalue(const std::string& option,      // If the user passes an unusable value for a command-line switch, it      // seems like a really bad idea to just ignore it, even with a log      // warning. -    throw LLCLPError(STRINGIZE("Invalid value specified by command-line switch '" << option -                               << "' for variable '" << varname << "' of type " << type -                               << ": '" << value << "'")); +    BOOST_THROW_EXCEPTION( +        LLCLPError(STRINGIZE("Invalid value specified by command-line switch '" << option +                             << "' for variable '" << varname << "' of type " << type +                             << ": '" << value << "'")));  }  template <typename T> diff --git a/indra/newview/llsecapi.cpp b/indra/newview/llsecapi.cpp index e871570786..bcb9417820 100644 --- a/indra/newview/llsecapi.cpp +++ b/indra/newview/llsecapi.cpp @@ -29,6 +29,7 @@  #include "llviewerprecompiledheaders.h"  #include "llsecapi.h"  #include "llsechandler_basic.h" +#include <boost/throw_exception.hpp>  #include <openssl/evp.h>  #include <openssl/err.h>  #include <map> @@ -69,7 +70,7 @@ void initializeSecHandler()  	}  	if (!exception_msg.empty())  // an exception was thrown.  	{ -		throw LLProtectedDataException(exception_msg); +		BOOST_THROW_EXCEPTION(LLProtectedDataException(exception_msg));  	}  } diff --git a/indra/newview/llsecapi.h b/indra/newview/llsecapi.h index 535a112638..6af5a28fa5 100644 --- a/indra/newview/llsecapi.h +++ b/indra/newview/llsecapi.h @@ -32,7 +32,7 @@  #include <openssl/x509.h>  #include <ostream>  #include "llpointer.h" -#include <stdexcept> +#include "llexception.h"  #ifdef LL_WINDOWS  #pragma warning(disable:4250) @@ -117,10 +117,10 @@ -struct LLProtectedDataException: public std::runtime_error +struct LLProtectedDataException: public LLException  {  	LLProtectedDataException(const std::string& msg): -		std::runtime_error(msg) +		LLException(msg)  	{  		LL_WARNS("SECAPI") << "Protected Data Error: " << msg << LL_ENDL;  	} @@ -331,11 +331,11 @@ std::ostream& operator <<(std::ostream& s, const LLCredential& cred);  // All error handling is via exceptions. -class LLCertException: public std::runtime_error +class LLCertException: public LLException  {  public:  	LLCertException(LLPointer<LLCertificate> cert, const std::string& msg): -		std::runtime_error(msg) +		LLException(msg)  	{  		mCert = cert; diff --git a/indra/newview/llsechandler_basic.cpp b/indra/newview/llsechandler_basic.cpp index 40516f9bbb..39ce64ad0e 100644 --- a/indra/newview/llsechandler_basic.cpp +++ b/indra/newview/llsechandler_basic.cpp @@ -35,6 +35,7 @@  #include "llfile.h"  #include "lldir.h"  #include "llviewercontrol.h" +#include <boost/throw_exception.hpp>  #include <vector>  #include <ios>  #include <openssl/ossl_typ.h> @@ -72,14 +73,14 @@ LLBasicCertificate::LLBasicCertificate(const std::string& pem_cert)  	if(pem_bio == NULL)  	{  		LL_WARNS("SECAPI") << "Could not allocate an openssl memory BIO." << LL_ENDL; -		throw LLInvalidCertificate(this); +		BOOST_THROW_EXCEPTION(LLInvalidCertificate(this));  	}  	mCert = NULL;  	PEM_read_bio_X509(pem_bio, &mCert, 0, NULL);  	BIO_free(pem_bio);  	if (!mCert)  	{ -		throw LLInvalidCertificate(this); +		BOOST_THROW_EXCEPTION(LLInvalidCertificate(this));  	}  } @@ -88,7 +89,7 @@ LLBasicCertificate::LLBasicCertificate(X509* pCert)  {  	if (!pCert || !pCert->cert_info)  	{ -		throw LLInvalidCertificate(this); +		BOOST_THROW_EXCEPTION(LLInvalidCertificate(this));  	}	  	mCert = X509_dup(pCert);  } @@ -873,22 +874,22 @@ void _validateCert(int validation_policy,  	// check basic properties exist in the cert  	if(!current_cert_info.has(CERT_SUBJECT_NAME) || !current_cert_info.has(CERT_SUBJECT_NAME_STRING))  	{ -		throw LLCertException(cert, "Cert doesn't have a Subject Name");				 +		BOOST_THROW_EXCEPTION(LLCertException(cert, "Cert doesn't have a Subject Name"));				  	}  	if(!current_cert_info.has(CERT_ISSUER_NAME_STRING))  	{ -		throw LLCertException(cert, "Cert doesn't have an Issuer Name");				 +		BOOST_THROW_EXCEPTION(LLCertException(cert, "Cert doesn't have an Issuer Name"));				  	}  	// check basic properties exist in the cert  	if(!current_cert_info.has(CERT_VALID_FROM) || !current_cert_info.has(CERT_VALID_TO))  	{ -		throw LLCertException(cert, "Cert doesn't have an expiration period");				 +		BOOST_THROW_EXCEPTION(LLCertException(cert, "Cert doesn't have an expiration period"));				  	}  	if (!current_cert_info.has(CERT_SHA1_DIGEST))  	{ -		throw LLCertException(cert, "No SHA1 digest"); +		BOOST_THROW_EXCEPTION(LLCertException(cert, "No SHA1 digest"));  	}  	if (validation_policy & VALIDATION_POLICY_TIME) @@ -903,7 +904,7 @@ void _validateCert(int validation_policy,  		if((validation_date < current_cert_info[CERT_VALID_FROM].asDate()) ||  		   (validation_date > current_cert_info[CERT_VALID_TO].asDate()))  		{ -			throw LLCertValidationExpirationException(cert, validation_date); +			BOOST_THROW_EXCEPTION(LLCertValidationExpirationException(cert, validation_date));  		}  	}  	if (validation_policy & VALIDATION_POLICY_SSL_KU) @@ -914,14 +915,14 @@ void _validateCert(int validation_policy,  			!(_LLSDArrayIncludesValue(current_cert_info[CERT_KEY_USAGE],   									  LLSD((std::string)CERT_KU_KEY_ENCIPHERMENT)))))  		{ -			throw LLCertKeyUsageValidationException(cert); +			BOOST_THROW_EXCEPTION(LLCertKeyUsageValidationException(cert));  		}  		// only validate EKU if the cert has it  		if(current_cert_info.has(CERT_EXTENDED_KEY_USAGE) && current_cert_info[CERT_EXTENDED_KEY_USAGE].isArray() &&	     		   (!_LLSDArrayIncludesValue(current_cert_info[CERT_EXTENDED_KEY_USAGE],   									LLSD((std::string)CERT_EKU_SERVER_AUTH))))  		{ -			throw LLCertKeyUsageValidationException(cert);			 +			BOOST_THROW_EXCEPTION(LLCertKeyUsageValidationException(cert));			  		}  	}  	if (validation_policy & VALIDATION_POLICY_CA_KU) @@ -930,7 +931,7 @@ void _validateCert(int validation_policy,  			(!_LLSDArrayIncludesValue(current_cert_info[CERT_KEY_USAGE],   									   (std::string)CERT_KU_CERT_SIGN)))  			{ -				throw LLCertKeyUsageValidationException(cert);						 +				BOOST_THROW_EXCEPTION(LLCertKeyUsageValidationException(cert));						  			}  	} @@ -942,13 +943,13 @@ void _validateCert(int validation_policy,  		if(!current_cert_info[CERT_BASIC_CONSTRAINTS].has(CERT_BASIC_CONSTRAINTS_CA) ||  		   !current_cert_info[CERT_BASIC_CONSTRAINTS][CERT_BASIC_CONSTRAINTS_CA])  		{ -				throw LLCertBasicConstraintsValidationException(cert); +				BOOST_THROW_EXCEPTION(LLCertBasicConstraintsValidationException(cert));  		}  		if (current_cert_info[CERT_BASIC_CONSTRAINTS].has(CERT_BASIC_CONSTRAINTS_PATHLEN) &&  			((current_cert_info[CERT_BASIC_CONSTRAINTS][CERT_BASIC_CONSTRAINTS_PATHLEN].asInteger() != 0) &&  			 (depth > current_cert_info[CERT_BASIC_CONSTRAINTS][CERT_BASIC_CONSTRAINTS_PATHLEN].asInteger())))  		{ -			throw LLCertBasicConstraintsValidationException(cert);					 +			BOOST_THROW_EXCEPTION(LLCertBasicConstraintsValidationException(cert));					  		}  	}  } @@ -1018,7 +1019,7 @@ void LLBasicCertificateStore::validate(int validation_policy,  	if(cert_chain->size() < 1)  	{ -		throw LLCertException(NULL, "No certs in chain"); +		BOOST_THROW_EXCEPTION(LLCertException(NULL, "No certs in chain"));  	}  	iterator current_cert = cert_chain->begin();  	LLSD 	current_cert_info; @@ -1033,11 +1034,11 @@ void LLBasicCertificateStore::validate(int validation_policy,  		(*current_cert)->getLLSD(current_cert_info);  		if(!validation_params.has(CERT_HOSTNAME))  		{ -			throw LLCertException((*current_cert), "No hostname passed in for validation");			 +			BOOST_THROW_EXCEPTION(LLCertException((*current_cert), "No hostname passed in for validation"));			  		}  		if(!current_cert_info.has(CERT_SUBJECT_NAME) || !current_cert_info[CERT_SUBJECT_NAME].has(CERT_NAME_CN))  		{ -			throw LLInvalidCertificate((*current_cert));				 +			BOOST_THROW_EXCEPTION(LLInvalidCertificate((*current_cert)));				  		}  		LL_DEBUGS("SECAPI") << "Validating the hostname " << validation_params[CERT_HOSTNAME].asString() <<  @@ -1054,7 +1055,7 @@ void LLBasicCertificateStore::validate(int validation_policy,  	X509* cert_x509 = (*current_cert)->getOpenSSLX509();  	if(!cert_x509)  	{ -		throw LLInvalidCertificate((*current_cert));			 +		BOOST_THROW_EXCEPTION(LLInvalidCertificate((*current_cert)));			  	}  	std::string sha1_hash((const char *)cert_x509->sha1_hash, SHA_DIGEST_LENGTH);  	X509_free( cert_x509 ); @@ -1075,7 +1076,7 @@ void LLBasicCertificateStore::validate(int validation_policy,  			if((validation_date < cache_entry->second.first) ||  			   (validation_date > cache_entry->second.second))  			{ -				throw LLCertValidationExpirationException((*current_cert), validation_date); +				BOOST_THROW_EXCEPTION(LLCertValidationExpirationException((*current_cert), validation_date));  			}  		}  		// successfully found in cache @@ -1107,7 +1108,7 @@ void LLBasicCertificateStore::validate(int validation_policy,  			if(!_verify_signature((*current_cert),  								  previous_cert))  			{ -			   throw LLCertValidationInvalidSignatureException(previous_cert); +			   BOOST_THROW_EXCEPTION(LLCertValidationInvalidSignatureException(previous_cert));  			}  		}  		_validateCert(local_validation_policy, @@ -1156,7 +1157,7 @@ void LLBasicCertificateStore::validate(int validation_policy,  			if(!_verify_signature((*found_store_cert),  								  (*current_cert)))  			{ -				throw LLCertValidationInvalidSignatureException(*current_cert); +				BOOST_THROW_EXCEPTION(LLCertValidationInvalidSignatureException(*current_cert));  			}			  			// successfully validated.  			mTrustedCertCache[sha1_hash] = std::pair<LLDate, LLDate>(from_time, to_time);		 @@ -1173,7 +1174,7 @@ void LLBasicCertificateStore::validate(int validation_policy,  	if (validation_policy & VALIDATION_POLICY_TRUSTED)  	{  		// we reached the end without finding a trusted cert. -		throw LLCertValidationTrustException((*cert_chain)[cert_chain->size()-1]); +		BOOST_THROW_EXCEPTION(LLCertValidationTrustException((*cert_chain)[cert_chain->size()-1]));  	}  	mTrustedCertCache[sha1_hash] = std::pair<LLDate, LLDate>(from_time, to_time);	 @@ -1261,7 +1262,7 @@ void LLSecAPIBasicHandler::_readProtectedData()  		protected_data_stream.read((char *)salt, STORE_SALT_SIZE);  		if (protected_data_stream.gcount() < STORE_SALT_SIZE)  		{ -			throw LLProtectedDataException("Config file too short."); +			BOOST_THROW_EXCEPTION(LLProtectedDataException("Config file too short."));  		}  		cipher.decrypt(salt, STORE_SALT_SIZE);		 @@ -1301,7 +1302,7 @@ void LLSecAPIBasicHandler::_readProtectedData()  		if (parser->parse(parse_stream, mProtectedDataMap,   						  LLSDSerialize::SIZE_UNLIMITED) == LLSDParser::PARSE_FAILURE)  		{ -			throw LLProtectedDataException("Config file cannot be decrypted."); +			BOOST_THROW_EXCEPTION(LLProtectedDataException("Config file cannot be decrypted."));  		}  	}  } @@ -1372,7 +1373,7 @@ void LLSecAPIBasicHandler::_writeProtectedData()  		// EXP-1825 crash in LLSecAPIBasicHandler::_writeProtectedData()  		// Decided throwing an exception here was overkill until we figure out why this happens -		//throw LLProtectedDataException("Error writing Protected Data Store"); +		//BOOST_THROW_EXCEPTION(LLProtectedDataException("Error writing Protected Data Store"));  	}      try @@ -1387,7 +1388,7 @@ void LLSecAPIBasicHandler::_writeProtectedData()              // EXP-1825 crash in LLSecAPIBasicHandler::_writeProtectedData()              // Decided throwing an exception here was overkill until we figure out why this happens -            //throw LLProtectedDataException("Could not overwrite protected data store"); +            //BOOST_THROW_EXCEPTION(LLProtectedDataException("Could not overwrite protected data store"));          }  	}  	catch (...) @@ -1401,7 +1402,7 @@ void LLSecAPIBasicHandler::_writeProtectedData()  		//crash in LLSecAPIBasicHandler::_writeProtectedData()  		// Decided throwing an exception here was overkill until we figure out why this happens -		//throw LLProtectedDataException("Error writing Protected Data Store"); +		//BOOST_THROW_EXCEPTION(LLProtectedDataException("Error writing Protected Data Store"));  	}  } diff --git a/indra/viewer_components/updater/llupdatedownloader.cpp b/indra/viewer_components/updater/llupdatedownloader.cpp index 382689afa0..cd4b108c1a 100644 --- a/indra/viewer_components/updater/llupdatedownloader.cpp +++ b/indra/viewer_components/updater/llupdatedownloader.cpp @@ -27,9 +27,10 @@  #include "llupdatedownloader.h"  #include "httpcommon.h" -#include <stdexcept> +#include "llexception.h"  #include <boost/format.hpp>  #include <boost/lexical_cast.hpp> +#include <boost/throw_exception.hpp>  #include <curl/curl.h>  #include "lldir.h"  #include "llevents.h" @@ -85,11 +86,11 @@ private:  namespace {  	class DownloadError: -		public std::runtime_error +		public LLException  	{  	public:  		DownloadError(const char * message): -			std::runtime_error(message) +			LLException(message)  		{  			; // No op.  		} @@ -467,7 +468,7 @@ void LLUpdateDownloader::Implementation::initializeCurlGet(std::string const & u  	if(!mCurl)  	{ -		throw DownloadError("failed to initialize curl"); +		BOOST_THROW_EXCEPTION(DownloadError("failed to initialize curl"));  	}      throwOnCurlError(curl_easy_setopt(mCurl.get(), CURLOPT_NOSIGNAL, true));  	throwOnCurlError(curl_easy_setopt(mCurl.get(), CURLOPT_FOLLOWLOCATION, true)); @@ -508,7 +509,7 @@ void LLUpdateDownloader::Implementation::resumeDownloading(size_t startByte)  	mHeaderList = curl_slist_append(mHeaderList, rangeHeaderFormat.str().c_str());  	if(mHeaderList == 0)  	{ -		throw DownloadError("cannot add Range header"); +		BOOST_THROW_EXCEPTION(DownloadError("cannot add Range header"));  	}  	throwOnCurlError(curl_easy_setopt(mCurl.get(), CURLOPT_HTTPHEADER, mHeaderList)); @@ -524,7 +525,7 @@ void LLUpdateDownloader::Implementation::startDownloading(LLURI const & uri, std  	mDownloadData["hash"] = hash;  	mDownloadData["current_version"] = ll_get_version();  	LLSD path = uri.pathArray(); -	if(path.size() == 0) throw DownloadError("no file path"); +	if(path.size() == 0) BOOST_THROW_EXCEPTION(DownloadError("no file path"));  	std::string fileName = path[path.size() - 1].asString();  	std::string filePath = gDirUtilp->getExpandedFilename(LL_PATH_TEMP, fileName);  	mDownloadData["path"] = filePath; @@ -547,9 +548,9 @@ void LLUpdateDownloader::Implementation::throwOnCurlError(CURLcode code)  	if(code != CURLE_OK) {  		const char * errorString = curl_easy_strerror(code);  		if(errorString != 0) { -			throw DownloadError(curl_easy_strerror(code)); +			BOOST_THROW_EXCEPTION(DownloadError(curl_easy_strerror(code)));  		} else { -			throw DownloadError("unknown curl error"); +			BOOST_THROW_EXCEPTION(DownloadError("unknown curl error"));  		}  	} else {  		; // No op. diff --git a/indra/viewer_components/updater/llupdateinstaller.cpp b/indra/viewer_components/updater/llupdateinstaller.cpp index 4432c6574e..9f9a08f590 100644 --- a/indra/viewer_components/updater/llupdateinstaller.cpp +++ b/indra/viewer_components/updater/llupdateinstaller.cpp @@ -30,17 +30,18 @@  #include "llupdateinstaller.h"  #include "lldir.h"   #include "llsd.h" +#include "llexception.h"  #if defined(LL_WINDOWS)  #pragma warning(disable: 4702)      // disable 'unreachable code' so we can use lexical_cast (really!).  #endif  #include <boost/lexical_cast.hpp> -#include <stdexcept> +#include <boost/throw_exception.hpp>  namespace { -	struct RelocateError: public std::runtime_error +	struct RelocateError: public LLException  	{ -		RelocateError(): std::runtime_error("llupdateinstaller: RelocateError") {} +		RelocateError(): LLException("llupdateinstaller: RelocateError") {}  	};  	std::string copy_to_temp(std::string const & path) @@ -48,7 +49,7 @@ namespace {  		std::string scriptFile = gDirUtilp->getBaseFileName(path);  		std::string newPath = gDirUtilp->getExpandedFilename(LL_PATH_TEMP, scriptFile);  		apr_status_t status = apr_file_copy(path.c_str(), newPath.c_str(), APR_FILE_SOURCE_PERMS, gAPRPoolp); -		if(status != APR_SUCCESS) throw RelocateError(); +		if(status != APR_SUCCESS) BOOST_THROW_EXCEPTION(RelocateError());  		return newPath;  	} diff --git a/indra/viewer_components/updater/llupdaterservice.cpp b/indra/viewer_components/updater/llupdaterservice.cpp index 788955a1b2..0bdd1ede43 100644 --- a/indra/viewer_components/updater/llupdaterservice.cpp +++ b/indra/viewer_components/updater/llupdaterservice.cpp @@ -35,6 +35,7 @@  #include <boost/scoped_ptr.hpp>  #include <boost/weak_ptr.hpp> +#include <boost/throw_exception.hpp>  #include "lldir.h"  #include "llsdserialize.h"  #include "llfile.h" @@ -190,8 +191,9 @@ void LLUpdaterServiceImpl::initialize(const std::string&  channel,  {  	if(mIsChecking || mIsDownloading)  	{ -		throw LLUpdaterService::UsageError("LLUpdaterService::initialize call " -										   "while updater is running."); +		BOOST_THROW_EXCEPTION( +			LLUpdaterService::UsageError("LLUpdaterService::initialize call " +										 "while updater is running."));  	}  	mChannel = channel; @@ -222,8 +224,9 @@ void LLUpdaterServiceImpl::startChecking(bool install_if_ready)  {  	if(mChannel.empty() || mVersion.empty())  	{ -		throw LLUpdaterService::UsageError("Set params before call to " -			"LLUpdaterService::startCheck()."); +		BOOST_THROW_EXCEPTION( +			LLUpdaterService::UsageError("Set params before call to " +										 "LLUpdaterService::startCheck()."));  	}  	mIsChecking = true; diff --git a/indra/viewer_components/updater/llupdaterservice.h b/indra/viewer_components/updater/llupdaterservice.h index 95bbe1695c..78e8c6b290 100644 --- a/indra/viewer_components/updater/llupdaterservice.h +++ b/indra/viewer_components/updater/llupdaterservice.h @@ -29,16 +29,17 @@  #include <boost/shared_ptr.hpp>  #include <boost/function.hpp>  #include "llhasheduniqueid.h" +#include "llexception.h"  class LLUpdaterServiceImpl;  class LLUpdaterService  {  public: -	class UsageError: public std::runtime_error +	class UsageError: public LLException  	{  	public: -		UsageError(const std::string& msg) : std::runtime_error(msg) {} +		UsageError(const std::string& msg) : LLException(msg) {}  	};  	// Name of the event pump through which update events will be delivered. | 
