From 1d2e489c7fdff1554111229fc3695f6f07a35fd4 Mon Sep 17 00:00:00 2001 From: qPCR4vir Date: Sun, 14 Apr 2019 23:28:28 +0200 Subject: [PATCH] full error msg at one place --- include/nana/gui/place.hpp | 40 ++++++++++++++++++++++---------------- source/gui/place.cpp | 3 +-- 2 files changed, 24 insertions(+), 19 deletions(-) diff --git a/include/nana/gui/place.hpp b/include/nana/gui/place.hpp index 24cf9382..56f27f34 100644 --- a/include/nana/gui/place.hpp +++ b/include/nana/gui/place.hpp @@ -1,16 +1,16 @@ -/* +/** * An Implementation of Place for Layout * Nana C++ Library(http://www.nanapro.org) - * Copyright(C) 2003-2018 Jinhao(cnjinhao@hotmail.com) + * Copyright(C) 2003-2019 Jinhao(cnjinhao@hotmail.com) * * Distributed under the Boost Software License, Version 1.0. * (See accompanying file LICENSE_1_0.txt or copy at * http://www.boost.org/LICENSE_1_0.txt) * - * @file: nana/gui/place.cpp + * @file nana/gui/place.cpp * - * @contributions: - * min/max and splitter bar initial weight by Ariel Vina-Rodriguez. + * @contributions + * error, width/height, min/max and splitter bar initial weight by Ariel Vina-Rodriguez. */ #ifndef NANA_GUI_PLACE_HPP @@ -104,23 +104,29 @@ namespace nana virtual void _m_add_agent(const detail::place_agent&) = 0; }; public: - class error :public ::std::invalid_argument + class error :public std::invalid_argument { public: - error(::std::string what, + error( const std::string& what, const place& plc, std::string field = "unknown", std::string::size_type pos = std::string::npos) - : std::invalid_argument(what), - owner_caption{ API::window_caption(plc.window_handle()).substr(0,80) }, - field{ field }, - div_text{ plc.div() }, - pos{ pos } + : std::invalid_argument{ "Place error " + what + + " from widget " + API::window_caption(plc.window_handle()).substr(0,80) + + " in fleld " + field + + ( pos == std::string::npos ? "" : "at at position " + std::to_string(pos) ) + + "in div_text:\n" + plc.div()}, + base_what { what }, + owner_caption{ API::window_caption(plc.window_handle()).substr(0,80) }, + field { field }, + div_text { plc.div() }, + pos { pos } {} - std::string owner_caption; ///< truncate caption (title) of the "placed" widget - std::string div_text; - std::string field; ///< posible field where the error ocurred. + std::string base_what; + std::string owner_caption; ///< truncate caption (title) of the "placed" widget + std::string div_text; ///< involved div_text + std::string field; ///< posible field where the error ocurred. std::string::size_type pos; ///< posible position in the div_text where the error ocurred. npos if unknown }; /// reference to a field manipulator which refers to a field object created by place @@ -139,8 +145,8 @@ namespace nana void splitter_renderer(std::function fn); - void div(std::string div_text); ///< Divides the attached widget into fields. - const std::string& div() const noexcept; ///< Returns div-text that depends on fields status. + void div(std::string div_text); ///< Divides the attached widget into fields. May throw placa::error + const std::string& div() const noexcept; ///< Returns div-text that depends on fields status. static bool valid_field_name(const char* name) ///< must begin with _a-zA-Z { return name && (*name == '_' || (('a' <= *name && *name <= 'z') || ('A' <= *name && *name <= 'Z'))); diff --git a/source/gui/place.cpp b/source/gui/place.cpp index a9177e28..b6cc7804 100644 --- a/source/gui/place.cpp +++ b/source/gui/place.cpp @@ -59,8 +59,7 @@ namespace nana error(std::string what, const tokenizer& tok) - : std::invalid_argument{ what + " from tokenizer at position " - + std::to_string(static_cast(tok.sp_ - tok.divstr_)) }, + : std::invalid_argument{ what + " from tokenizer " }, pos{static_cast(tok.sp_ - tok.divstr_)} {} std::string::size_type pos;