1 // Copyright 2005 Ben Hutchings <ben@decadent.org.uk>.
2 // See the file "COPYING" for licence details.
9 #include "xpcom_support.hpp"
11 namespace xpcom_support
13 void throw_exception(nsresult error)
15 assert(NS_ERROR_GET_SEVERITY(error) == NS_ERROR_SEVERITY_ERROR);
17 // TODO: look up error message
19 std::sprintf(message, "XPCOM error %08x", error);
23 case NS_ERROR_OUT_OF_MEMORY:
24 throw std::bad_alloc();
26 case NS_ERROR_NOT_INITIALIZED:
27 case NS_ERROR_ALREADY_INITIALIZED:
28 case NS_ERROR_INVALID_POINTER:
29 case NS_ERROR_ILLEGAL_VALUE:
30 case NS_BASE_STREAM_CLOSED:
31 case NS_BASE_STREAM_ILLEGAL_ARGS:
32 assert(!"internal error detected by XPCOM function");
33 throw std::logic_error(message);
36 throw std::runtime_error(message);