2010-04-21 00:12:02 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
|
|
|
* vim: sw=4 ts=4 et :
|
|
|
|
*/
|
2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2010-04-21 00:12:02 +04:00
|
|
|
|
2010-04-29 04:38:41 +04:00
|
|
|
#include <stdio.h>
|
2010-04-21 00:12:02 +04:00
|
|
|
|
2011-08-31 22:05:20 +04:00
|
|
|
#include "mozalloc_abort.h"
|
|
|
|
|
2010-04-29 04:38:41 +04:00
|
|
|
__declspec(noreturn) static void abort_from_exception(const char* const which,
|
|
|
|
const char* const what);
|
|
|
|
static void
|
|
|
|
abort_from_exception(const char* const which, const char* const what)
|
|
|
|
{
|
|
|
|
fprintf(stderr, "fatal: STL threw %s: ", which);
|
|
|
|
mozalloc_abort(what);
|
|
|
|
}
|
2010-04-21 00:12:02 +04:00
|
|
|
|
|
|
|
namespace std {
|
|
|
|
|
|
|
|
// NB: user code is not supposed to touch the std:: namespace. We're
|
|
|
|
// doing this after careful review because we want to define our own
|
|
|
|
// exception throwing semantics. Don't try this at home!
|
|
|
|
|
2015-08-21 12:43:10 +03:00
|
|
|
MFBT_API __declspec(noreturn) void
|
2010-04-29 04:38:41 +04:00
|
|
|
moz_Xinvalid_argument(const char* what)
|
|
|
|
{
|
|
|
|
abort_from_exception("invalid_argument", what);
|
|
|
|
}
|
|
|
|
|
2015-08-21 12:43:10 +03:00
|
|
|
MFBT_API __declspec(noreturn) void
|
2010-04-29 04:38:41 +04:00
|
|
|
moz_Xlength_error(const char* what)
|
|
|
|
{
|
|
|
|
abort_from_exception("length_error", what);
|
|
|
|
}
|
|
|
|
|
2015-08-21 12:43:10 +03:00
|
|
|
MFBT_API __declspec(noreturn) void
|
2010-04-29 04:38:41 +04:00
|
|
|
moz_Xout_of_range(const char* what)
|
|
|
|
{
|
|
|
|
abort_from_exception("out_of_range", what);
|
|
|
|
}
|
|
|
|
|
2015-08-21 12:43:10 +03:00
|
|
|
MFBT_API __declspec(noreturn) void
|
2010-04-29 04:38:41 +04:00
|
|
|
moz_Xoverflow_error(const char* what)
|
|
|
|
{
|
|
|
|
abort_from_exception("overflow_error", what);
|
|
|
|
}
|
2010-04-21 00:12:02 +04:00
|
|
|
|
2015-08-21 12:43:10 +03:00
|
|
|
MFBT_API __declspec(noreturn) void
|
2010-04-29 04:38:41 +04:00
|
|
|
moz_Xruntime_error(const char* what)
|
2010-04-21 00:12:02 +04:00
|
|
|
{
|
2010-04-29 04:38:41 +04:00
|
|
|
abort_from_exception("runtime_error", what);
|
2010-04-21 00:12:02 +04:00
|
|
|
}
|
|
|
|
|
2015-07-13 18:25:42 +03:00
|
|
|
} // namespace std
|