Skip to content
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

Polish calculator customs #6

Open
wants to merge 25 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Add handling of stoi exception
  • Loading branch information
KEK committed Dec 17, 2019
commit 5e3bbe41dd9844b8585103a0e27352b501a6a5ad
6 changes: 2 additions & 4 deletions Parser/Parser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,14 @@ bool Parser::parse(const std::string& data) {
std::string math_operator = string_matches_operator(buffer);
if (!math_operator.empty()) {
operators_->push_back(math_operator);
continue;
}

try {
int number = std::stoi(buffer);
numbers_->push(number);
} catch (const std::exception& exception) {
// KEK

// TODO: Figure out how to handle this exception
// (if it should be)
std::cerr << "cannot convert "<< buffer << " to number!" << std::endl;
}
}

Expand Down