Skip to content

Commit c8d7718

Browse files
Cleanup throws in irep serialization
1 parent c521824 commit c8d7718

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

src/util/irep_serialization.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ Date: May 2007
1616
#include <sstream>
1717
#include <iostream>
1818

19+
#include "exception_utils.h"
1920
#include "string_hash.h"
2021

2122
void irep_serializationt::write_irep(
@@ -95,8 +96,7 @@ void irep_serializationt::read_irep(
9596

9697
if(in.get()!=0)
9798
{
98-
std::cerr << "irep not terminated\n";
99-
throw 0;
99+
throw deserialization_exceptiont("irep not terminated");
100100
}
101101
}
102102

@@ -150,7 +150,7 @@ std::size_t irep_serializationt::insert_on_read(
150150
std::pair<bool, irept>(false, get_nil_irep()));
151151

152152
if(ireps_container.ireps_on_read[id].first)
153-
throw "irep id read twice.";
153+
throw deserialization_exceptiont("irep id read twice.");
154154
else
155155
{
156156
ireps_container.ireps_on_read[id]=

src/util/json_irep.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Author: Thomas Kiley, [email protected]
1111

1212
#include "json_irep.h"
1313

14+
#include "exception_utils.h"
1415
#include "irep.h"
1516
#include "json.h"
1617

@@ -103,8 +104,11 @@ irept json_irept::convert_from_json(const jsont &in) const
103104
have_keys.push_back(keyval.first);
104105
std::sort(have_keys.begin(), have_keys.end());
105106
if(have_keys!=std::vector<std::string>{"comment", "id", "namedSub", "sub"})
106-
throw "irep JSON representation is missing one of needed keys: "
107-
"'id', 'sub', 'namedSub', 'comment'";
107+
{
108+
throw deserialization_exceptiont(
109+
"irep JSON representation is missing one of needed keys: "
110+
"'id', 'sub', 'namedSub', 'comment'");
111+
}
108112

109113
irept out(in["id"].value);
110114

0 commit comments

Comments
 (0)