Skip to content

Cleanup throws in irep (de)serialization #2960

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/util/irep_serialization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Date: May 2007
#include <sstream>
#include <iostream>

#include "exception_utils.h"
#include "string_hash.h"

void irep_serializationt::write_irep(
Expand Down Expand Up @@ -95,8 +96,7 @@ void irep_serializationt::read_irep(

if(in.get()!=0)
{
std::cerr << "irep not terminated\n";
throw 0;
throw deserialization_exceptiont("irep not terminated");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is this caught?

Copy link
Contributor Author

@hannes-steffenhagen-diffblue hannes-steffenhagen-diffblue Sep 18, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch (no pun intended) I'd forgotten about that (I originally introduced something like a cprover_exception_baset and caught that, but then decided against it as I didn't find it saved that much effort compared to not having it...)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@peterschrammel This is now sorted with #2996

}
}

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

if(ireps_container.ireps_on_read[id].first)
throw "irep id read twice.";
throw deserialization_exceptiont("irep id read twice.");
else
{
ireps_container.ireps_on_read[id]=
Expand Down
8 changes: 6 additions & 2 deletions src/util/json_irep.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Author: Thomas Kiley, [email protected]

#include "json_irep.h"

#include "exception_utils.h"
#include "irep.h"
#include "json.h"

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

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

Expand Down