Skip to content

Consistently throw a std::string (not char const *) #10

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
12 changes: 6 additions & 6 deletions edn.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ namespace edn {
else if (validSymbol(token.value))
node.type = EdnSymbol;
else
throw "Could not parse atom";
throw string("Could not parse atom");

return node;
}
Expand Down Expand Up @@ -316,7 +316,7 @@ namespace edn {
//special case where we return early as # { is a set - thus tagname is empty
node.type = EdnSet;
if (value.type != EdnMap) {
throw "Was expection a { } after hash to build set";
throw string("Was expection a { } after hash to build set");
}
node.values = value.values;
return node;
Expand All @@ -325,7 +325,7 @@ namespace edn {
}

if (!validSymbol(tagName)) {
throw "Invalid tag name";
throw string("Invalid tag name");
}

EdnToken symToken;
Expand Down Expand Up @@ -358,7 +358,7 @@ namespace edn {
if (token.value == "{") closeParen = "}";

while (true) {
if (tokens.empty()) throw "unexpected end of list";
if (tokens.empty()) throw string("unexpected end of list");

nextToken = shiftToken(tokens);

Expand All @@ -369,7 +369,7 @@ namespace edn {
}
}
} else if (token.value == ")" || token.value == "]" || token.value == "}") {
throw "Unexpected " + token.value;
throw string("Unexpected " + token.value);
} else {
if (token.value.size() && token.value.at(0) == '#') {
return handleTagged(token, readAhead(shiftToken(tokens), tokens));
Expand Down Expand Up @@ -446,7 +446,7 @@ namespace edn {
list<EdnToken> tokens = lex(edn);

if (tokens.size() == 0) {
throw "No parsable tokens found in string";
throw string("No parsable tokens found in string");
}

return readAhead(shiftToken(tokens), tokens);
Expand Down