From: Jay Freeman (saurik) Date: Sat, 12 Dec 2015 14:07:07 +0000 (-0800) Subject: Catch errors during replace and output to console. X-Git-Tag: v0.9.590~225 X-Git-Url: https://git.saurik.com/cycript.git/commitdiff_plain/311fe5f36238b8a8c80e49fa85dbac81fec58887?ds=sidebyside Catch errors during replace and output to console. --- diff --git a/Console.cpp b/Console.cpp index 494e179..4cf0ac1 100644 --- a/Console.cpp +++ b/Console.cpp @@ -646,6 +646,7 @@ static void Console(CYOptions &options) { free(line); if (command.empty()) continue; + history += command; if (command[0] == '?') { std::string data(command.substr(1)); @@ -671,14 +672,13 @@ static void Console(CYOptions &options) { *out_ << "lower == " << (lower ? "true" : "false") << std::endl; } - history += command; continue; } std::string code; if (bypass) code = command; - else { + else try { std::istringstream stream(command); CYPool pool; @@ -707,7 +707,6 @@ static void Console(CYOptions &options) { std::cerr << " | "; std::cerr << error->message_ << std::endl; - history += command; break; } @@ -722,10 +721,12 @@ static void Console(CYOptions &options) { Setup(out, driver, options, lower); out << *driver.script_; code = str.str(); + } catch (const CYException &error) { + CYPool pool; + std::cout << error.PoolCString(pool) << std::endl; + continue; } - history += command; - if (debug) { std::cout << "cy= "; CYLexerHighlight(code.c_str(), code.size(), std::cout); @@ -1098,6 +1099,7 @@ int Main(int argc, char * const argv[], char const * const envp[]) { if (failed || !driver.errors_.empty()) { for (CYDriver::Errors::const_iterator i(driver.errors_.begin()); i != driver.errors_.end(); ++i) std::cerr << i->location_.begin << ": " << i->message_ << std::endl; + return 1; } else if (driver.script_ != NULL) { std::stringbuf str; CYOutput out(str, options);