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