From 953e17722dac0922e2a647cea7d288b06aeecb80 Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Wed, 24 Mar 2021 20:25:44 +0100 Subject: [PATCH] throw hr_exceptions not strings --- asonov.cpp | 2 +- binary-tiling.cpp | 2 +- goldberg.cpp | 2 +- nonisotropic.cpp | 8 ++++---- reg3.cpp | 2 +- util.cpp | 8 ++++---- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/asonov.cpp b/asonov.cpp index 420a80dd..d73b5b5e 100644 --- a/asonov.cpp +++ b/asonov.cpp @@ -53,7 +53,7 @@ coord coord::addmove(int d) { case 9: return down().shift(1, 2); case 10: return shift(-1, 0); case 11: return shift(0, -1); - default: throw "error"; + default: throw hr_exception("error"); } } diff --git a/binary-tiling.cpp b/binary-tiling.cpp index f5dd0d13..2f585bd5 100644 --- a/binary-tiling.cpp +++ b/binary-tiling.cpp @@ -526,7 +526,7 @@ EX namespace bt { case bd_up_right: return xpush(-log(2)) * parabolic(1); default: - throw "unknown direction"; + throw hr_exception("unknown direction"); } else if(use_direct_for(dir)) return cgi.direct_tmatrix[dir]; diff --git a/goldberg.cpp b/goldberg.cpp index 6ed4de46..46317089 100644 --- a/goldberg.cpp +++ b/goldberg.cpp @@ -1207,7 +1207,7 @@ EX namespace gp { return cw.at; } } - throw "unimplemented"; + throw hr_exception("unimplemented"); } transmatrix adj(cell *c, int d) override { diff --git a/nonisotropic.cpp b/nonisotropic.cpp index b947275d..b7d0d1f6 100644 --- a/nonisotropic.cpp +++ b/nonisotropic.cpp @@ -373,7 +373,7 @@ EX namespace sn { return NULL; } - default: throw "not solnihv"; + default: throw hr_exception("not solnihv"); } } @@ -452,7 +452,7 @@ EX namespace sn { case gSol: up = 2; down = 6; break; case gSolN: up = 4; down = 7; break; case gNIH: up = 4; down = 4; break; - default: throw "not nihsolv"; + default: throw hr_exception("not nihsolv"); } while(h1->distance > h2->distance) front = front * adj(h1, down), h1 = h1->cmove(down); @@ -526,7 +526,7 @@ EX namespace sn { 0 ); default: - throw "christoffel not in solnihv"; + throw hr_exception("christoffel not in solnihv"); } } @@ -690,7 +690,7 @@ EX namespace sn { case gSol: return solt; case gNIH: return niht; case gSolN: return sont; - default: throw "not solnih"; + default: throw hr_exception("not solnih"); } } diff --git a/reg3.cpp b/reg3.cpp index 7ccdd64a..b38e6cc8 100644 --- a/reg3.cpp +++ b/reg3.cpp @@ -1197,7 +1197,7 @@ EX namespace reg3 { res = at; } - if(!res) throw "res missing"; + if(!res) throw hr_exception("res missing"); if(res->move(d2)) println(hlog, "res conflict"); diff --git a/util.cpp b/util.cpp index f12daa98..356275df 100644 --- a/util.cpp +++ b/util.cpp @@ -666,14 +666,14 @@ EX string compress_string(string s) { strm.opaque = Z_NULL; println(hlog, "pre init"); auto ret = deflateInit(&strm, 9); - if(ret != Z_OK) throw "z-error"; + if(ret != Z_OK) throw hr_exception("z-error"); println(hlog, "init ok"); strm.avail_in = isize(s); strm.next_in = (Bytef*) &s[0]; vector buf(1000000, 0); strm.avail_out = 1000000; strm.next_out = (Bytef*) &buf[0]; - if(deflate(&strm, Z_FINISH) != Z_STREAM_END) throw "z-error-2"; + if(deflate(&strm, Z_FINISH) != Z_STREAM_END) throw hr_exception("z-error-2"); println(hlog, "deflate ok"); string out(&buf[0], (char*)(strm.next_out) - &buf[0]); println(hlog, isize(s), " -> ", isize(out)); @@ -686,13 +686,13 @@ EX string decompress_string(string s) { strm.zfree = Z_NULL; strm.opaque = Z_NULL; auto ret = inflateInit(&strm); - if(ret != Z_OK) throw "z-error"; + if(ret != Z_OK) throw hr_exception("z-error"); strm.avail_in = isize(s); strm.next_in = (Bytef*) &s[0]; vector buf(1000000, 0); strm.avail_out = 1000000; strm.next_out = (Bytef*) &buf[0]; - if(inflate(&strm, Z_FINISH) != Z_STREAM_END) throw "z-error-2"; + if(inflate(&strm, Z_FINISH) != Z_STREAM_END) throw hr_exception("z-error-2"); string out(&buf[0], (char*)(strm.next_out) - &buf[0]); println(hlog, isize(s), " -> ", isize(out)); return out;