Changed no-exception behaviour to call throw_exception directly so that the handler sees the actual error message.

[SVN r20361]
This commit is contained in:
John Maddock
2003-10-13 11:45:11 +00:00
parent ff1c0a0bb5
commit 54e9a2fbcb
4 changed files with 12 additions and 35 deletions

View File

@ -375,15 +375,12 @@ void BOOST_REGEX_CALL re_message_update()
if(*boost::re_detail::c_traits_base::get_catalogue()) if(*boost::re_detail::c_traits_base::get_catalogue())
{ {
message_cat = catopen(boost::re_detail::c_traits_base::get_catalogue(), 0); message_cat = catopen(boost::re_detail::c_traits_base::get_catalogue(), 0);
#ifndef BOOST_NO_EXCEPTIONS
if(message_cat == (nl_catd)-1) if(message_cat == (nl_catd)-1)
{ {
std::string m("Unable to open message catalog: "); std::string m("Unable to open message catalog: ");
throw std::runtime_error(m + boost::re_detail::c_traits_base::get_catalogue()); std::runtime_error err(m + boost::re_detail::c_traits_base::get_catalogue());
boost::throw_exception(err);
} }
#else
BOOST_REGEX_NOEH_ASSERT(message_cat != (nl_catd)-1);
#endif
} }
#endif #endif
for(int i = 0; i < boost::REG_E_UNKNOWN; ++i) for(int i = 0; i < boost::REG_E_UNKNOWN; ++i)

View File

@ -205,15 +205,12 @@ message_data<char>::message_data(const std::locale& l, std::string regex_message
{ {
pm = &BOOST_USE_FACET(std::messages<char>, l); pm = &BOOST_USE_FACET(std::messages<char>, l);
cat = pm->open(regex_message_catalogue, l); cat = pm->open(regex_message_catalogue, l);
#ifndef BOOST_NO_EXCEPTIONS
if(cat < 0) if(cat < 0)
{ {
std::string m("Unable to open message catalog: "); std::string m("Unable to open message catalog: ");
throw std::runtime_error(m + regex_message_catalogue); std::runtime_error err(m + regex_message_catalogue);
boost::throw_exception(err);
} }
#else
BOOST_REGEX_NOEH_ASSERT(cat >= 0);
#endif
} }
#endif #endif
std::memset(syntax_map, cpp_regex_traits<char>::syntax_char, 256); std::memset(syntax_map, cpp_regex_traits<char>::syntax_char, 256);
@ -613,15 +610,12 @@ message_data<wchar_t>::message_data(const std::locale& l, const std::string& reg
if(regex_message_catalogue.size()) if(regex_message_catalogue.size())
{ {
cat = msgs.open(regex_message_catalogue, l); cat = msgs.open(regex_message_catalogue, l);
#ifndef BOOST_NO_EXCEPTIONS
if(cat < 0) if(cat < 0)
{ {
std::string m("Unable to open message catalog: "); std::string m("Unable to open message catalog: ");
throw std::runtime_error(m + regex_message_catalogue); std::runtime_error err(m + regex_message_catalogue);
boost::throw_exception(err);
} }
#else
BOOST_REGEX_NOEH_ASSERT(cat >= 0);
#endif
} }
#endif #endif
scoped_array<char> a; scoped_array<char> a;

View File

@ -83,11 +83,8 @@ void mapfile::open(const char* file)
CloseHandle(hfile); CloseHandle(hfile);
hmap = 0; hmap = 0;
hfile = 0; hfile = 0;
#ifndef BOOST_NO_EXCEPTIONS std::runtime_error err("Unable to create file mapping.");
throw std::runtime_error("Unable to create file mapping."); boost::throw_exception(err);
#else
BOOST_REGEX_NOEH_ASSERT(hmap != INVALID_HANDLE_VALUE);
#endif
} }
_first = static_cast<const char*>(MapViewOfFile(hmap, FILE_MAP_READ, 0, 0, 0)); _first = static_cast<const char*>(MapViewOfFile(hmap, FILE_MAP_READ, 0, 0, 0));
if(_first == 0) if(_first == 0)
@ -96,11 +93,7 @@ void mapfile::open(const char* file)
CloseHandle(hfile); CloseHandle(hfile);
hmap = 0; hmap = 0;
hfile = 0; hfile = 0;
#ifndef BOOST_NO_EXCEPTIONS std::runtime_error err("Unable to create file mapping.");
throw std::runtime_error("Unable to create file mapping.");
#else
BOOST_REGEX_NOEH_ASSERT(_first != 0);
#endif
} }
_last = _first + GetFileSize(hfile, 0); _last = _first + GetFileSize(hfile, 0);
} }
@ -322,11 +315,7 @@ void mapfile::open(const char* file)
} }
else else
{ {
#ifndef BOOST_NO_EXCEPTIONS std::runtime_error err("Unable to open file.");
throw std::runtime_error("Unable to open file.");
#else
BOOST_REGEX_NOEH_ASSERT(hfile != 0);
#endif
} }
#ifndef BOOST_NO_EXCEPTIONS #ifndef BOOST_NO_EXCEPTIONS
}catch(...) }catch(...)

View File

@ -236,15 +236,12 @@ void BOOST_REGEX_CALL w32_traits_base::do_init()
if(*regex_message_catalogue) if(*regex_message_catalogue)
{ {
hresmod = LoadLibraryA(regex_message_catalogue); hresmod = LoadLibraryA(regex_message_catalogue);
#ifndef BOOST_NO_EXCEPTIONS
if(hresmod == NULL) if(hresmod == NULL)
{ {
std::string s("Unable to open dll: "); std::string s("Unable to open dll: ");
throw std::runtime_error(s + regex_message_catalogue); std::runtime_error err(s + regex_message_catalogue);
boost::throw_exception(err);
} }
#else
BOOST_REGEX_NOEH_ASSERT(hresmod != NULL);
#endif
} }
unsigned int i; unsigned int i;
for(i = 0; i < REG_E_UNKNOWN; ++i) for(i = 0; i < REG_E_UNKNOWN; ++i)