From 06675305ba719e3396e699d59783f09f6986786c Mon Sep 17 00:00:00 2001 From: moneroexamples Date: Sun, 24 Apr 2016 12:15:08 +0800 Subject: [PATCH] cheking if lexical_cast is ok --- src/page.h | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/src/page.h b/src/page.h index 32d6871..c9bcaf6 100644 --- a/src/page.h +++ b/src/page.h @@ -868,16 +868,29 @@ namespace xmreg { // first check if searching for block of given height - if (search_text.size() < 12) + if (search_text.size() < 12) { - result_html = show_block(boost::lexical_cast(search_text)); + uint64_t blk_height; - // nasty check if output is "Cant get" as a sign of - // a not found tx. Later need to think of something better. - if (result_html.find("Cant get") == string::npos) + try { - return result_html; + blk_height = boost::lexical_cast(search_text); + + result_html = show_block(blk_height); + + // nasty check if output is "Cant get" as a sign of + // a not found tx. Later need to think of something better. + if (result_html.find("Cant get") == string::npos) + { + return result_html; + } + + } + catch(boost::bad_lexical_cast &e) + { + cerr << search_text << " is not a number" << endl; } + } // second let try searching for tx