Replacing std::exception with std::runtime_error

This commit is contained in:
doctaweed 2020-08-26 22:24:03 -06:00
parent 311e025fe9
commit 92976234a1
31 changed files with 123 additions and 123 deletions

View File

@ -227,35 +227,35 @@ std::string Type::print_method_info() const {
NoneType::NoneType() : Type("", "none", false) {}
bool NoneType::is_reference() const {
throw std::exception("is_reference called on NoneType");
throw std::runtime_error("is_reference called on NoneType");
}
int NoneType::get_load_size() const {
throw std::exception("get_load_size called on NoneType");
throw std::runtime_error("get_load_size called on NoneType");
}
bool NoneType::get_load_signed() const {
throw std::exception("get_load_size called on NoneType");
throw std::runtime_error("get_load_size called on NoneType");
}
int NoneType::get_size_in_memory() const {
throw std::exception("get_size_in_memory called on NoneType");
throw std::runtime_error("get_size_in_memory called on NoneType");
}
RegKind NoneType::get_preferred_reg_kind() const {
throw std::exception("get_preferred_reg_kind called on NoneType");
throw std::runtime_error("get_preferred_reg_kind called on NoneType");
}
int NoneType::get_offset() const {
throw std::exception("get_offset called on NoneType");
throw std::runtime_error("get_offset called on NoneType");
}
int NoneType::get_in_memory_alignment() const {
throw std::exception("get_in_memory_alignment called on NoneType");
throw std::runtime_error("get_in_memory_alignment called on NoneType");
}
int NoneType::get_inline_array_alignment() const {
throw std::exception("get_inline_array_alignment called on NoneType");
throw std::runtime_error("get_inline_array_alignment called on NoneType");
}
std::string NoneType::print() const {

View File

@ -32,7 +32,7 @@ Type* TypeSystem::add_type(const std::string& name, std::unique_ptr<Type> type)
// update the type
m_types[name] = std::move(type);
} else {
throw std::exception("Type was redefined with throw_on_redefine set.");
throw std::runtime_error("Type was redefined with throw_on_redefine set.");
}
}
} else {
@ -43,13 +43,13 @@ Type* TypeSystem::add_type(const std::string& name, std::unique_ptr<Type> type)
if (m_forward_declared_types.find(type->get_parent()) != m_forward_declared_types.end()) {
fmt::print("[TypeSystem] Type {} has incompletely defined parent {}\n", type->get_name(),
type->get_parent());
throw std::exception("add_type failed");
throw std::runtime_error("add_type failed");
}
if (m_types.find(type->get_parent()) == m_types.end()) {
fmt::print("[TypeSystem] Type {} has undefined parent {}\n", type->get_name(),
type->get_parent());
throw std::exception("add_type failed");
throw std::runtime_error("add_type failed");
}
}
@ -135,7 +135,7 @@ TypeSpec TypeSystem::make_typespec(const std::string& name) {
return TypeSpec(name);
} else {
fmt::print("[TypeSystem] The type {} is unknown.\n", name);
throw std::exception("make_typespec failed");
throw std::runtime_error("make_typespec failed");
}
}
@ -199,7 +199,7 @@ Type* TypeSystem::lookup_type(const std::string& name) {
fmt::print("[TypeSystem] The type {} is not defined.\n", name);
}
throw std::exception("lookup_type failed");
throw std::runtime_error("lookup_type failed");
}
/*!
@ -254,7 +254,7 @@ MethodInfo TypeSystem::add_method(Type* type, const std::string& method_name, co
method_name, type->get_name(), existing_info.type.print(), ts.print());
// unlike type re-definition, method re-definition is almost certain to go wrong.
// probably better to give up.
throw std::exception("method redefinition");
throw std::runtime_error("method redefinition");
}
return existing_info;
@ -278,7 +278,7 @@ MethodInfo TypeSystem::add_new_method(Type* type, const TypeSpec& ts) {
"[TypeSystem] The new method of {} was originally defined as {}, but has been redefined "
"as {}\n",
type->get_name(), existing.type.print(), ts.print());
throw std::exception("add_new_method failed");
throw std::runtime_error("add_new_method failed");
}
return existing;
@ -317,7 +317,7 @@ MethodInfo TypeSystem::lookup_method(const std::string& type_name, const std::st
}
fmt::print("[TypeSystem] The method {} of type {} could not be found.\n", method_name, type_name);
throw std::exception("lookup_method failed");
throw std::runtime_error("lookup_method failed");
}
/*!
@ -345,7 +345,7 @@ MethodInfo TypeSystem::lookup_new_method(const std::string& type_name) {
}
fmt::print("[TypeSystem] The new method of type {} could not be found.\n", type_name);
throw std::exception("lookup_new_method failed");
throw std::runtime_error("lookup_new_method failed");
}
/*!
@ -420,7 +420,7 @@ void TypeSystem::assert_field_offset(const std::string& type_name,
if (field.offset() != offset) {
fmt::print("[TypeSystem] assert_field_offset({}, {}, {}) failed - got {}\n", type_name,
field_name, offset);
throw std::exception("assert_field_offset failed");
throw std::runtime_error("assert_field_offset failed");
}
}
@ -436,7 +436,7 @@ int TypeSystem::add_field_to_type(StructureType* type,
int offset_override) {
if (type->lookup_field(field_name, nullptr)) {
fmt::print("[TypeSystem] Type {} already has a field named {}\n", type->get_name(), field_name);
throw std::exception("add_field_to_type duplicate field names");
throw std::runtime_error("add_field_to_type duplicate field names");
}
// first, construct the field
@ -467,7 +467,7 @@ int TypeSystem::add_field_to_type(StructureType* type,
"[TypeSystem] Tried to overwrite offset of field to be {}, but it is not aligned "
"correctly\n",
offset);
throw std::exception("add_field_to_type bad offset_override");
throw std::runtime_error("add_field_to_type bad offset_override");
}
}
@ -649,7 +649,7 @@ Field TypeSystem::lookup_field(const std::string& type_name, const std::string&
Field field;
if (!type->lookup_field(field_name, &field)) {
fmt::print("[TypeSystem] Type {} has no field named {}\n", type_name, field_name);
throw std::exception("lookup_field failed");
throw std::runtime_error("lookup_field failed");
}
return field;
}

View File

@ -76,7 +76,7 @@ class TypeSystem {
auto x = lookup_type(type_name);
T* result = dynamic_cast<T*>(x);
if (!result) {
throw std::exception("Failed to get the right type");
throw std::runtime_error("Failed to get the right type");
}
return result;
}

View File

@ -272,7 +272,7 @@ void LinkedObjectFile::append_word_to_string(std::string& dest, const LinkedWord
sprintf(buff, " .sym-off 0x%x %s\n", word.data >> 16, word.symbol_name.c_str());
break;
default:
throw std::exception("nyi");
throw std::runtime_error("nyi");
}
dest += buff;

View File

@ -134,7 +134,7 @@ static uint32_t c_symlink2(LinkedObjectFile& f,
word_kind = LinkedWord::TYPE_PTR;
break;
default:
throw std::exception("unhandled SymbolLinkKind");
throw std::runtime_error("unhandled SymbolLinkKind");
}
f.symbol_link_word(seg_id, code_ptr_offset - initial_offset, name, word_kind);
@ -191,7 +191,7 @@ static uint32_t c_symlink3(LinkedObjectFile& f,
word_kind = LinkedWord::TYPE_PTR;
break;
default:
throw std::exception("unhandled SymbolLinkKind");
throw std::runtime_error("unhandled SymbolLinkKind");
}
f.symbol_link_word(seg, code_ptr - initial_offset, name, word_kind);

View File

@ -16,7 +16,7 @@ std::string combine_path(const std::string& parent, const std::string& child) {
std::vector<uint8_t> read_binary_file(const std::string& filename) {
auto fp = fopen(filename.c_str(), "rb");
if(!fp) throw std::exception("File cannot be opened");
if(!fp) throw std::runtime_error("File cannot be opened");
fseek(fp, 0, SEEK_END);
auto len = ftell(fp);
rewind(fp);
@ -25,7 +25,7 @@ std::vector<uint8_t> read_binary_file(const std::string& filename) {
data.resize(len);
if(fread(data.data(), len, 1, fp) != 1) {
throw std::exception("File cannot be read");
throw std::runtime_error("File cannot be read");
}
return data;
@ -75,7 +75,7 @@ void write_text_file(const std::string& file_name, const std::string& text) {
FILE* fp = fopen(file_name.c_str(), "w");
if(!fp) {
printf("Failed to fopen %s\n", file_name.c_str());
throw std::exception("Failed to open file");
throw std::runtime_error("Failed to open file");
}
fprintf(fp, "%s\n", text.c_str());
fclose(fp);

View File

@ -72,7 +72,7 @@ void Form::buildStringSimple(std::string &str) {
str.append(*token.str);
break;
default:
throw std::exception("buildStringSimple unknown token kind");
throw std::runtime_error("buildStringSimple unknown token kind");
}
}
}
@ -110,7 +110,7 @@ void Form::toTokenList(std::vector<FormToken> &tokens) {
tokens.emplace_back(TokenKind::EMPTY_PAIR);
break;
default:
throw std::exception("unhandled form type in buildSimpleString");
throw std::runtime_error("unhandled form type in buildSimpleString");
break;
}
}

View File

@ -70,7 +70,7 @@ struct FormToken {
s.append(*str);
break;
default:
throw std::exception("toString unknown token kind");
throw std::runtime_error("toString unknown token kind");
}
return s;
}

View File

@ -40,7 +40,7 @@ struct Ptr {
if (offset) {
return (T*)(g_ee_main_mem + offset);
} else {
throw std::exception("Ptr null dereference!");
throw std::runtime_error("Ptr null dereference!");
}
}
@ -51,7 +51,7 @@ struct Ptr {
if (offset) {
return *(T*)(g_ee_main_mem + offset);
} else {
throw std::exception("Ptr null dereference!");
throw std::runtime_error("Ptr null dereference!");
}
}

View File

@ -264,7 +264,7 @@ uint32_t cross_seg_dist_link_v3(Ptr<uint8_t> link,
} else if (size == 8) {
*Ptr<int64_t>(offset_of_patch).c() = diff;
} else {
throw std::exception("unknown size in cross_seg_dist_link_v3");
throw std::runtime_error("unknown size in cross_seg_dist_link_v3");
}
return 1 + 3 * 4;

View File

@ -338,10 +338,10 @@ s32 cvt_float(float x, s32 precision, s32* lead_char, char* buff_start, char* bu
value = (char)rounder;
} else if (!(ru32 >> 31)) { // sign bit
value = 0;
throw std::exception("got very large exponent in rounding calculation");
throw std::runtime_error("got very large exponent in rounding calculation");
} else {
value = -1; // happens on NaN's
// throw std::exception("got negative sign bit in rounding calculation");
// throw std::runtime_error("got negative sign bit in rounding calculation");
}
// place number at the end of the buffer and move pointer back
@ -386,10 +386,10 @@ s32 cvt_float(float x, s32 precision, s32* lead_char, char* buff_start, char* bu
value = (char)next_int;
} else if (!(ru32 >> 0x1f)) {
value = 0;
throw std::exception("got very large exponent in rounding calculation");
throw std::runtime_error("got very large exponent in rounding calculation");
} else {
value = -1; // happens on NaN's
// throw std::exception("got negative sign bit in rounding calculation");
// throw std::runtime_error("got negative sign bit in rounding calculation");
}
*count_chrp = value + '0';
count_chrp++;
@ -401,7 +401,7 @@ s32 cvt_float(float x, s32 precision, s32* lead_char, char* buff_start, char* bu
// however, the rounding flag is always disabled and the rounding code doesn't work.
if ((fraction_part != 0.f) && ((flags & 1) != 0)) {
start_ptr = round(fraction_part, nullptr, start_ptr, count_chrp - 1, 0, lead_char);
throw std::exception("cvt_float called round!");
throw std::runtime_error("cvt_float called round!");
}
}
@ -553,7 +553,7 @@ char* kitoa(char* buffer, s64 value, u64 base, s32 length, char pad, u32 flag) {
* uses C varags, but 128-bit varags don't work, so "format" always passes 0 for quadword printing.
*/
void kqtoa() {
throw std::exception("kqtoa not implemented");
throw std::runtime_error("kqtoa not implemented");
}
struct format_struct {
@ -791,7 +791,7 @@ s32 format_impl(uint64_t* args) {
}
kstrinsert(output_ptr, pad, desired_length - print_len);
} else {
throw std::exception("unsupported justify in format");
throw std::runtime_error("unsupported justify in format");
// output_ptr = strend(output_ptr);
// while(0 < (desired_length - print_len)) {
// char pad = ' ';
@ -842,7 +842,7 @@ s32 format_impl(uint64_t* args) {
kstrinsert(output_ptr, pad, desired_length - print_len);
} else {
throw std::exception("unsupported justify in format");
throw std::runtime_error("unsupported justify in format");
// output_ptr = strend(output_ptr);
// u32 l140 = 0;
// while(l140 < (desired_length - print_len)) {
@ -883,7 +883,7 @@ s32 format_impl(uint64_t* args) {
call_method_of_type(in, type, GOAL_PRINT_FUNC);
}
} else {
throw std::exception("failed to find symbol in format!");
throw std::runtime_error("failed to find symbol in format!");
}
}
output_ptr = strend(output_ptr);
@ -904,7 +904,7 @@ s32 format_impl(uint64_t* args) {
call_method_of_type(in, type, GOAL_INSPECT_FUNC);
}
} else {
throw std::exception("failed to find symbol in format!");
throw std::runtime_error("failed to find symbol in format!");
}
}
output_ptr = strend(output_ptr);
@ -912,7 +912,7 @@ s32 format_impl(uint64_t* args) {
case 'Q': // not yet implemented. hopefully andy gavin finishes this one soon.
case 'q':
throw std::exception("nyi q format string");
throw std::runtime_error("nyi q format string");
break;
case 'X': // hex, 64 bit, pad padchar
@ -1009,7 +1009,7 @@ s32 format_impl(uint64_t* args) {
precision = 4;
float value;
if (in < 0) {
throw std::exception("time seconds format error negative.\n");
throw std::runtime_error("time seconds format error negative.\n");
} else {
value = in;
}
@ -1025,7 +1025,7 @@ s32 format_impl(uint64_t* args) {
default:
MsgErr("format: unknown code 0x%02x\n", format_ptr[1]);
throw std::exception("format error");
throw std::runtime_error("format error");
break;
}
format_ptr++;
@ -1067,13 +1067,13 @@ s32 format_impl(uint64_t* args) {
*PrintPendingLocal3 = 0;
return 0;
} else if (type == *Ptr<Ptr<Type>>(s7.offset + FIX_SYM_FILE_STREAM_TYPE)) {
throw std::exception("FORMAT into a file stream not supported");
throw std::runtime_error("FORMAT into a file stream not supported");
}
}
throw std::exception("unknown format destination");
throw std::runtime_error("unknown format destination");
return 0;
}
throw std::exception("how did we get here?");
throw std::runtime_error("how did we get here?");
return 7;
}

View File

@ -124,7 +124,7 @@ u64 goal_malloc(u32 heap, u32 size, u32 flags, u32 name) {
*/
u64 alloc_from_heap(u32 heapSymbol, u32 type, s32 size) {
if (size <= 0) {
throw std::exception("got <= 0 size allocation in alloc_from_heap!");
throw std::runtime_error("got <= 0 size allocation in alloc_from_heap!");
}
// align to 16 bytes (part one)
@ -162,7 +162,7 @@ u64 alloc_from_heap(u32 heapSymbol, u32 type, s32 size) {
return kmalloc(*Ptr<Ptr<kheapinfo>>(heapSymbol), size, KMALLOC_MEMSET, gstr->data()).offset;
} else if (heapOffset == FIX_SYM_PROCESS_TYPE) {
throw std::exception("this type of process allocation is not supported yet!\n");
throw std::runtime_error("this type of process allocation is not supported yet!\n");
// allocate on current process heap
// Ptr start = *ptr<Ptr>(getS6() + 0x4c + 8);
// Ptr heapEnd = *ptr<Ptr>(getS6() + 0x4c + 4);
@ -178,7 +178,7 @@ u64 alloc_from_heap(u32 heapSymbol, u32 type, s32 size) {
// alignedSize); return 0;
// }
} else if (heapOffset == FIX_SYM_SCRATCH) {
throw std::exception("this type of scratchpad allocation is not used!\n");
throw std::runtime_error("this type of scratchpad allocation is not used!\n");
} else {
memset(Ptr<u8>(heapSymbol).c(), 0, (size_t)alignedSize); // treat it as a stack address
return heapSymbol;
@ -920,7 +920,7 @@ u64 call_method_of_type(u32 arg, Ptr<Type> type, u32 method_id) {
(*type_tag).offset);
}
}
// throw std::exception("call_method_of_type failed!\n");
// throw std::runtime_error("call_method_of_type failed!\n");
printf("[ERROR] call_method_of_type failed!\n");
printf("type is %s\n", info(type->symbol)->str->data());
return arg;
@ -958,7 +958,7 @@ u64 call_method_of_type_arg2(u32 arg, Ptr<Type> type, u32 method_id, u32 a1, u32
(*type_tag).offset);
}
}
throw std::exception("call_method_of_type failed!\n");
throw std::runtime_error("call_method_of_type failed!\n");
return arg;
}

View File

@ -63,7 +63,7 @@ void deci2_runner(SystemThreadInterface& interfaces) {
// server.wait_for_protos_ready();
// // then allow the server to accept connections
// if (!server.init()) {
// throw std::exception("DECI2 server init failed");
// throw std::runtime_error("DECI2 server init failed");
// }
//
// printf("[DECI2] waiting for listener...\n");

View File

@ -201,12 +201,12 @@ s32 CreateSema(SemaParam* param) {
s32 WaitSema(s32 sema) {
(void)sema;
throw std::exception("NYI");
throw std::runtime_error("NYI");
}
s32 SignalSema(s32 sema) {
(void)sema;
throw std::exception("NYI");
throw std::runtime_error("NYI");
}
s32 WakeupThread(s32 thid) {

View File

@ -6,33 +6,33 @@ namespace ee {
s32 sceOpen(const char *filename, s32 flag) {
(void)filename;
(void)flag;
throw std::exception("sceOpen NYI");
throw std::runtime_error("sceOpen NYI");
}
s32 sceClose(s32 fd) {
(void)fd;
throw std::exception("sceClose NYI");
throw std::runtime_error("sceClose NYI");
}
s32 sceRead(s32 fd, void *buf, s32 nbyte) {
(void)fd;
(void)buf;
(void)nbyte;
throw std::exception("sceRead NYI");
throw std::runtime_error("sceRead NYI");
}
s32 sceWrite(s32 fd, const void *buf, s32 nbyte) {
(void)fd;
(void)buf;
(void)nbyte;
throw std::exception("sceWrite NYI");
throw std::runtime_error("sceWrite NYI");
}
s32 sceLseek(s32 fd, s32 offset, s32 where) {
(void)fd;
(void)offset;
(void)where;
throw std::exception("sceLseek NYI");
throw std::runtime_error("sceLseek NYI");
}
int scePadPortOpen(int port, int slot, void* data) {

View File

@ -215,7 +215,7 @@ void Deci2Server::run() {
printf("[DECI2] Warning: no handler for this message, ignoring...\n");
unlock();
return;
// throw std::exception("no handler!");
// throw std::runtime_error("no handler!");
}
auto& driver = d2_drivers[handler];

View File

@ -7,9 +7,9 @@
* Create a new thread. Will not run the thread.
*/
s32 IOP_Kernel::CreateThread(std::string name, u32 (*func)()) {
if(_currentThread != -1) throw std::exception("tried to create thread from thread");
if(_currentThread != -1) throw std::runtime_error("tried to create thread from thread");
u32 ID = (u32)_nextThID++;
if(threads.size() != ID) throw std::exception("thread number error?");
if(threads.size() != ID) throw std::runtime_error("thread number error?");
// add entry
threads.emplace_back(name, func, ID, this);
// setup the thread!
@ -47,7 +47,7 @@ void IOP_Kernel::setupThread(s32 id) {
threads.at(id).waitForDispatch();
// printf("[IOP Kernel] Thread %s first dispatch!\n", threads.at(id).name.c_str());
if(_currentThread != id) {
throw std::exception("the wrong thread has run!\n");
throw std::runtime_error("the wrong thread has run!\n");
}
(threads.at(id).function)();
printf("Thread %s has returned!\n", threads.at(id).name.c_str());
@ -59,7 +59,7 @@ void IOP_Kernel::setupThread(s32 id) {
* Run a thread (call from kernel)
*/
void IOP_Kernel::runThread(s32 id) {
if(_currentThread != -1) throw std::exception("tried to runThread in a thread");
if(_currentThread != -1) throw std::runtime_error("tried to runThread in a thread");
_currentThread = id;
threads.at(id).dispatch();
threads.at(id).waitForReturnToKernel();
@ -76,7 +76,7 @@ void IOP_Kernel::SuspendThread() {
threads.at(oldThread).returnToKernel();
threads.at(oldThread).waitForDispatch();
if(_currentThread != oldThread) {
throw std::exception("bad resume");
throw std::runtime_error("bad resume");
}
}
@ -128,7 +128,7 @@ void IOP_Kernel::dispatchAll() {
*/
void IopThreadRecord::returnToKernel() {
runThreadReady = false;
if(kernel->getCurrentThread() != thID) throw std::exception("tried to sleep the wrong thread!");
if(kernel->getCurrentThread() != thID) throw std::runtime_error("tried to sleep the wrong thread!");
{
std::lock_guard<std::mutex> lck(*threadToKernelMutex);
@ -142,7 +142,7 @@ void IopThreadRecord::returnToKernel() {
*/
void IopThreadRecord::dispatch() {
syscallReady = false;
if(kernel->getCurrentThread() != thID) throw std::exception("tried to dispatch the wrong thread!");
if(kernel->getCurrentThread() != thID) throw std::runtime_error("tried to dispatch the wrong thread!");
{
std::lock_guard<std::mutex> lck(*kernelToThreadMutex);
runThreadReady = true;
@ -163,7 +163,7 @@ void IopThreadRecord::waitForReturnToKernel() {
* Thread waits for kernel to dispatch it.
*/
void IopThreadRecord::waitForDispatch() {
//if(kernel->getCurrentThread() == -1) throw std::exception("tried to suspend main!\n");
//if(kernel->getCurrentThread() == -1) throw std::runtime_error("tried to suspend main!\n");
std::unique_lock<std::mutex> lck(*kernelToThreadMutex);
kernelToThreadCV->wait(lck, [this]{return runThreadReady;});
//runThreadReady = false;

View File

@ -98,7 +98,7 @@ public:
* Resume the kernel.
*/
void returnToKernel() {
if(_currentThread < 0) throw std::exception("tried to return to kernel not in a thread");
if(_currentThread < 0) throw std::runtime_error("tried to return to kernel not in a thread");
threads[_currentThread].returnToKernel();
}
@ -129,7 +129,7 @@ public:
return -0x1a9;
}
// printf("poll %d %ld\n", mbx, mbxs.size());
if(mbx >= (s32) mbxs.size()) throw std::exception("invalid PollMbx");
if(mbx >= (s32) mbxs.size()) throw std::runtime_error("invalid PollMbx");
s32 gotSomething = mbxs[mbx].empty() ? 0 : 1;
if(gotSomething) {
void* thing = mbxs[mbx].front();
@ -146,7 +146,7 @@ public:
* Push something into a mbx
*/
s32 SendMbx(s32 mbx, void* value) {
if(mbx >= (s32) mbxs.size()) throw std::exception("invalid SendMbx");
if(mbx >= (s32) mbxs.size()) throw std::runtime_error("invalid SendMbx");
mbxs[mbx].push(value);
// printf("push into messagebox %d %p\n", mbx, value);
// printf("mbx size %ld\n", mbxs.size());

View File

@ -13,7 +13,7 @@
*/
SystemThread& SystemThreadManager::create_thread(const std::string& name) {
if (thread_count >= MAX_SYSTEM_THREADS) {
throw std::exception("Out of System Threads! Please increase MAX_SYSTEM_THREADS");
throw std::runtime_error("Out of System Threads! Please increase MAX_SYSTEM_THREADS");
}
auto& thread = threads[thread_count];

View File

@ -126,7 +126,7 @@ void Interpreter::execute_repl() {
Object evald = eval_with_rewind(obj, global_environment.as_env());
// print
printf("%s\n", evald.print().c_str());
} catch (std::exception& e) {
} catch (std::runtime_error& e) {
printf("REPL Error: %s\n", e.what());
}
}
@ -137,7 +137,7 @@ void Interpreter::execute_repl() {
* for debugging.
*/
void Interpreter::throw_eval_error(const Object& o, const std::string& err) {
// throw std::exception("[GOOS] Evaluation error on " + o.print() + ": " + err + "\n" +
// throw std::runtime_error("[GOOS] Evaluation error on " + o.print() + ": " + err + "\n" +
// reader.db.get_info_for(o));
}
@ -151,7 +151,7 @@ Object Interpreter::eval_with_rewind(const Object& obj,
Object result = EmptyListObject::make_new();
try {
result = eval(obj, env);
} catch (std::exception& e) {
} catch (std::runtime_error& e) {
if (!disable_printing) {
printf("-----------------------------------------\n");
printf("From object %s\nat %s\n", obj.inspect().c_str(), reader.db.get_info_for(obj).c_str());

View File

@ -49,7 +49,7 @@ Object Interpreter::eval_read(const Object& form,
try {
return reader.read_from_string(args.unnamed.at(0).as_string()->data);
} catch (std::exception& e) {
} catch (std::runtime_error& e) {
throw_eval_error(form, std::string("reader error inside of read:\n") + e.what());
}
@ -67,7 +67,7 @@ Object Interpreter::eval_read_file(const Object& form,
try {
return reader.read_from_file(args.unnamed.at(0).as_string()->data);
} catch (std::exception& e) {
} catch (std::runtime_error& e) {
throw_eval_error(form, std::string("reader error inside of read-file:\n") + e.what());
}
return EmptyListObject::make_new();
@ -85,13 +85,13 @@ Object Interpreter::eval_load_file(const Object& form,
Object o;
try {
o = reader.read_from_file(args.unnamed.at(0).as_string()->data);
} catch (std::exception& e) {
} catch (std::runtime_error& e) {
throw_eval_error(form, std::string("reader error inside of load-file:\n") + e.what());
}
try {
return eval_with_rewind(o, global_environment.as_env());
} catch (std::exception& e) {
} catch (std::runtime_error& e) {
throw_eval_error(form, std::string("eval error inside of load-file:\n") + e.what());
}
return EmptyListObject::make_new();

View File

@ -33,7 +33,7 @@ std::string object_type_to_string(ObjectType type) {
case ObjectType::ENVIRONMENT:
return "[environment]";
default:
throw std::exception("unknown object type in object_type_to_string");
throw std::runtime_error("unknown object type in object_type_to_string");
}
}
@ -151,7 +151,7 @@ bool Object::operator==(const Object& other) const {
}
default:
throw std::exception("equality not implemented for");
throw std::runtime_error("equality not implemented for");
}
}

View File

@ -222,7 +222,7 @@ class Object {
std::shared_ptr<PairObject> as_pair() const {
if (type != ObjectType::PAIR) {
// throw std::exception("as_pair called on a " + object_type_to_string(type) + " " +
// throw std::runtime_error("as_pair called on a " + object_type_to_string(type) + " " +
// print());
}
return std::dynamic_pointer_cast<PairObject>(heap_obj);
@ -230,14 +230,14 @@ class Object {
std::shared_ptr<EnvironmentObject> as_env() const {
if (type != ObjectType::ENVIRONMENT) {
// throw std::exception("as_env called on a " + object_type_to_string(type) + " " + print());
// throw std::runtime_error("as_env called on a " + object_type_to_string(type) + " " + print());
}
return std::dynamic_pointer_cast<EnvironmentObject>(heap_obj);
}
std::shared_ptr<SymbolObject> as_symbol() const {
if (type != ObjectType::SYMBOL) {
// throw std::exception("as_symbol called on a " + object_type_to_string(type) + " " +
// throw std::runtime_error("as_symbol called on a " + object_type_to_string(type) + " " +
// print());
}
return std::dynamic_pointer_cast<SymbolObject>(heap_obj);
@ -245,7 +245,7 @@ class Object {
std::shared_ptr<StringObject> as_string() const {
if (type != ObjectType::STRING) {
// throw std::exception("as_string called on a " + object_type_to_string(type) + " " +
// throw std::runtime_error("as_string called on a " + object_type_to_string(type) + " " +
// print());
}
return std::dynamic_pointer_cast<StringObject>(heap_obj);
@ -253,7 +253,7 @@ class Object {
std::shared_ptr<LambdaObject> as_lambda() const {
if (type != ObjectType::LAMBDA) {
// throw std::exception("as_lambda called on a " + object_type_to_string(type) + " " +
// throw std::runtime_error("as_lambda called on a " + object_type_to_string(type) + " " +
// print());
}
return std::dynamic_pointer_cast<LambdaObject>(heap_obj);
@ -261,7 +261,7 @@ class Object {
std::shared_ptr<MacroObject> as_macro() const {
if (type != ObjectType::MACRO) {
// throw std::exception("as_macro called on a " + object_type_to_string(type) + " " +
// throw std::runtime_error("as_macro called on a " + object_type_to_string(type) + " " +
// print());
}
return std::dynamic_pointer_cast<MacroObject>(heap_obj);
@ -269,7 +269,7 @@ class Object {
std::shared_ptr<ArrayObject> as_array() const {
if (type != ObjectType::ARRAY) {
// throw std::exception("as_array called on a " + object_type_to_string(type) + " " +
// throw std::runtime_error("as_array called on a " + object_type_to_string(type) + " " +
// print());
}
return std::dynamic_pointer_cast<ArrayObject>(heap_obj);
@ -277,14 +277,14 @@ class Object {
IntType& as_int() {
if (type != ObjectType::INTEGER) {
// throw std::exception("as_int called on a " + object_type_to_string(type) + " " + print());
// throw std::runtime_error("as_int called on a " + object_type_to_string(type) + " " + print());
}
return integer_obj.value;
}
FloatType& as_float() {
if (type != ObjectType::FLOAT) {
// throw std::exception("as_float called on a " + object_type_to_string(type) + " " +
// throw std::runtime_error("as_float called on a " + object_type_to_string(type) + " " +
// print());
}
return float_obj.value;
@ -292,7 +292,7 @@ class Object {
char& as_char() {
if (type != ObjectType::CHAR) {
// throw std::exception("as_char called on a " + object_type_to_string(type) + " " +
// throw std::runtime_error("as_char called on a " + object_type_to_string(type) + " " +
// print());
}
return char_obj.value;

View File

@ -102,7 +102,7 @@ Reader::Reader() {
// find the source directory
auto result = std::getenv("NEXT_DIR");
if (!result) {
throw std::exception(
throw std::runtime_error(
"Environment variable NEXT_DIR is not set. Please set this to point to next/");
}
@ -278,7 +278,7 @@ bool Reader::read_object(Token& tok, TextStream& ts, Object& obj) {
if (try_token_as_symbol(tok, obj)) {
return true;
}
} catch (std::exception& e) {
} catch (std::runtime_error& e) {
throw_reader_error(ts, "parsing token " + tok.text + " failed: " + e.what(), -1);
}
@ -564,7 +564,7 @@ bool Reader::try_token_as_float(const Token& tok, Object& obj) {
return false;
obj = Object::make_float(v);
return true;
} catch (std::exception& e) {
} catch (std::runtime_error& e) {
return false;
}
}
@ -627,8 +627,8 @@ bool Reader::try_token_as_hex(const Token& tok, Object& obj) {
return false;
obj = Object::make_integer(v);
return true;
} catch (std::exception& e) {
throw std::exception("The number cannot be a hexadecimal constant");
} catch (std::runtime_error& e) {
throw std::runtime_error("The number cannot be a hexadecimal constant");
}
}
return false;
@ -661,8 +661,8 @@ bool Reader::try_token_as_integer(const Token& tok, Object& obj) {
return false;
obj = Object::make_integer(v);
return true;
} catch (std::exception& e) {
throw std::exception("The number cannot be an integer constant");
} catch (std::runtime_error& e) {
throw std::runtime_error("The number cannot be an integer constant");
}
}
return false;
@ -697,7 +697,7 @@ bool Reader::try_token_as_char(const Token& tok, Object& obj) {
* Used for reader errors, like "missing close paren" or similar.
*/
void Reader::throw_reader_error(TextStream& here, const std::string& err, int seek_offset) {
throw std::exception("Reader error at");
throw std::runtime_error("Reader error at");
}
/*!

View File

@ -218,7 +218,7 @@ void Deci2Server::run() {
printf("[DECI2] Warning: no handler for this message, ignoring...\n");
unlock();
return;
// throw std::exception("no handler!");
// throw std::runtime_error("no handler!");
}
auto& driver = d2_drivers[handler];

View File

@ -43,7 +43,7 @@ bool Listener::is_connected() const {
/*
bool Listener::connect_to_target(const std::string& ip, int port) {
if (m_connected) {
throw std::exception("attempted a Listener::connect_to_target when already connected!");
throw std::runtime_error("attempted a Listener::connect_to_target when already connected!");
}
if (socket_fd >= 0) {

View File

@ -7,7 +7,7 @@ namespace util {
std::string read_text_file(const std::string& path) {
std::ifstream file(path);
if (!file.good()) {
throw std::exception("couldn't open ");
throw std::runtime_error("couldn't open ");
}
std::stringstream ss;
ss << file.rdbuf();

View File

@ -226,8 +226,8 @@ FMT_FUNC void system_error::init(int err_code, string_view format_str,
error_code_ = err_code;
memory_buffer buffer;
format_system_error(buffer, err_code, vformat(format_str, args));
std::exception& base = *this;
// base = std::exception(to_string(buffer));
std::runtime_error& base = *this;
// base = std::runtime_error(to_string(buffer));
}
namespace detail {
@ -1175,7 +1175,7 @@ int snprintf_float(T value, int precision, float_specs specs,
auto capacity = buf.capacity() - offset;
#ifdef FMT_FUZZ
if (precision > 100000)
throw std::exception(
throw std::runtime_error(
"fuzz mode - avoid large allocation inside snprintf");
#endif
// Suppress the warning about a nonliteral format string.
@ -1327,7 +1327,7 @@ FMT_FUNC detail::utf8_to_utf16::utf8_to_utf16(string_view s) {
auto cp = uint32_t();
auto error = 0;
p = utf8_decode(p, &cp, &error);
if (error != 0) FMT_THROW(std::exception("invalid utf8"));
if (error != 0) FMT_THROW(std::runtime_error("invalid utf8"));
if (cp <= 0xFFFF) {
buffer_.push_back(static_cast<wchar_t>(cp));
} else {

View File

@ -15,7 +15,7 @@ int format_float(char* buf, std::size_t size, const char* format, int precision,
T value) {
#ifdef FMT_FUZZ
if (precision > 100000)
throw std::exception(
throw std::runtime_error(
"fuzz mode - avoid large allocation inside snprintf");
#endif
// Suppress the warning about nonliteral format string.

View File

@ -683,7 +683,7 @@ class basic_memory_buffer : public detail::buffer<T> {
template <typename T, size_t SIZE, typename Allocator>
void basic_memory_buffer<T, SIZE, Allocator>::grow(size_t size) {
#ifdef FMT_FUZZ
if (size > 5000) throw std::exception("fuzz mode - won't grow that much");
if (size > 5000) throw std::runtime_error("fuzz mode - won't grow that much");
#endif
size_t old_capacity = this->capacity();
size_t new_capacity = old_capacity + old_capacity / 2;
@ -710,11 +710,11 @@ struct is_contiguous<basic_memory_buffer<T, SIZE, Allocator>> : std::true_type {
/** A formatting error such as invalid format string. */
FMT_CLASS_API
class FMT_API format_error : public std::exception {
class FMT_API format_error : public std::runtime_error {
public:
explicit format_error(const char* message) : std::exception(message) {}
explicit format_error(const char* message) : std::runtime_error(message) {}
explicit format_error(const std::string& message);
// : std::exception(message) {}
// : std::runtime_error(message) {}
format_error(const format_error&) = default;
format_error& operator=(const format_error&) = default;
format_error(format_error&&) = default;
@ -1145,7 +1145,7 @@ template <typename Char> class float_writer {
}
#ifdef FMT_FUZZ
if (num_zeros > 5000)
throw std::exception("fuzz mode - avoiding excessive cpu use");
throw std::runtime_error("fuzz mode - avoiding excessive cpu use");
#endif
it = std::fill_n(it, num_zeros, static_cast<Char>('0'));
}
@ -2952,14 +2952,14 @@ using arg_formatter FMT_DEPRECATED_ALIAS =
for example a file opening error.
*/
FMT_CLASS_API
class FMT_API system_error : public std::exception {
class FMT_API system_error : public std::runtime_error {
private:
void init(int err_code, string_view format_str, format_args args);
protected:
int error_code_;
system_error() : std::exception(""), error_code_(0) {}
system_error() : std::runtime_error(""), error_code_(0) {}
public:
/**
@ -2982,7 +2982,7 @@ class FMT_API system_error : public std::exception {
*/
template <typename... Args>
system_error(int error_code, string_view message, const Args&... args)
: std::exception("") {
: std::runtime_error("") {
init(error_code, message, make_format_args(args...));
}
system_error(const system_error&) = default;

View File

@ -2324,7 +2324,7 @@ namespace detail
/*!
@brief general exception of the @ref basic_json class
This class is an extension of `std::exception` objects with a member @a id for
This class is an extension of `std::runtime_error` objects with a member @a id for
exception ids. It is used as the base class for all exceptions thrown by the
@ref basic_json class. This class can hence be used as "wildcard" to catch
exceptions.
@ -2339,7 +2339,7 @@ Subclasses:
@internal
@note To have nothrow-copy-constructible exceptions, we internally use
`std::exception` which can cope with arbitrary-length error messages.
`std::runtime_error` which can cope with arbitrary-length error messages.
Intermediate strings are built with static functions and then passed to
the actual constructor.
@endinternal
@ -2349,7 +2349,7 @@ caught.,exception}
@since version 3.0.0
*/
class exception : public std::exception
class exception : public std::runtime_error
{
public:
/// returns the explanatory string
@ -2373,7 +2373,7 @@ class exception : public std::exception
private:
/// an exception object as storage for error messages
std::exception m;
std::runtime_error m;
};
/*!