mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2026-07-15 22:32:43 +00:00
throw hr_exceptions not strings
This commit is contained in:
@@ -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<char> 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<char> 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;
|
||||
|
||||
Reference in New Issue
Block a user