Added a warning_() macro
This commit is contained in:
parent
87ec7bc34a
commit
badea00584
4 changed files with 19 additions and 21 deletions
10
src/error.h
10
src/error.h
|
|
@ -64,6 +64,16 @@ inline void throw_func(const string& message) {
|
||||||
_desc_accum.clear(), \
|
_desc_accum.clear(), \
|
||||||
throw_func<cls>(_desc_buffer.str()))
|
throw_func<cls>(_desc_buffer.str()))
|
||||||
|
|
||||||
|
inline void warning_func(const string& message) {
|
||||||
|
std::cerr << "Warning: " << message << std::endl;
|
||||||
|
_desc_buffer.str("");
|
||||||
|
}
|
||||||
|
|
||||||
|
#define warning_(msg) \
|
||||||
|
((_desc_buffer << ACCUM(_desc_accum << msg)), \
|
||||||
|
_desc_accum.clear(), \
|
||||||
|
warning_func(_desc_buffer.str()))
|
||||||
|
|
||||||
extern straccstream _ctxt_accum;
|
extern straccstream _ctxt_accum;
|
||||||
extern std::ostringstream _ctxt_buffer;
|
extern std::ostringstream _ctxt_buffer;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -152,9 +152,7 @@ void python_interpreter_t::initialize()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (! path_initialized)
|
if (! path_initialized)
|
||||||
std::cerr
|
warning_(_("Ledger failed to find 'ledger/__init__.py' on the PYTHONPATH"));
|
||||||
<< _("Warning: Ledger failed to find 'ledger/__init__.py' on the PYTHONPATH")
|
|
||||||
<< std::endl;
|
|
||||||
}
|
}
|
||||||
catch (const error_already_set&) {
|
catch (const error_already_set&) {
|
||||||
PyErr_Print();
|
PyErr_Print();
|
||||||
|
|
|
||||||
|
|
@ -810,13 +810,9 @@ post_t * instance_t::parse_post(char * line,
|
||||||
post->account = account->find_account(name);
|
post->account = account->find_account(name);
|
||||||
|
|
||||||
if (honor_strict && strict && ! post->account->known) {
|
if (honor_strict && strict && ! post->account->known) {
|
||||||
if (post->_state == item_t::UNCLEARED) {
|
if (post->_state == item_t::UNCLEARED)
|
||||||
straccstream accum;
|
warning_(_("\"%1\", line %2: Unknown account '%3'")
|
||||||
std::cerr
|
<< pathname << linenum << post->account->fullname());
|
||||||
<< ACCUM(accum << _("Warning: \"%1\", line %2: Unknown account '%3'")
|
|
||||||
<< pathname << linenum << post->account->fullname())
|
|
||||||
<< std::endl;
|
|
||||||
}
|
|
||||||
post->account->known = true;
|
post->account->known = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -840,13 +836,9 @@ post_t * instance_t::parse_post(char * line,
|
||||||
if (! post->amount.is_null() && honor_strict && strict &&
|
if (! post->amount.is_null() && honor_strict && strict &&
|
||||||
post->amount.has_commodity() &&
|
post->amount.has_commodity() &&
|
||||||
! post->amount.commodity().has_flags(COMMODITY_KNOWN)) {
|
! post->amount.commodity().has_flags(COMMODITY_KNOWN)) {
|
||||||
if (post->_state == item_t::UNCLEARED) {
|
if (post->_state == item_t::UNCLEARED)
|
||||||
straccstream accum;
|
warning_(_("\"%1\", line %2: Unknown commodity '%3'")
|
||||||
std::cerr
|
<< pathname << linenum << post->amount.commodity());
|
||||||
<< ACCUM(accum << _("Warning: \"%1\", line %2: Unknown commodity '%3'")
|
|
||||||
<< pathname << linenum << post->amount.commodity())
|
|
||||||
<< std::endl;
|
|
||||||
}
|
|
||||||
post->amount.commodity().add_flags(COMMODITY_KNOWN);
|
post->amount.commodity().add_flags(COMMODITY_KNOWN);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -300,8 +300,7 @@ void trace_dtor_func(void * ptr, const char * cls_name, std::size_t cls_size)
|
||||||
|
|
||||||
live_objects_map::iterator i = live_objects->find(ptr);
|
live_objects_map::iterator i = live_objects->find(ptr);
|
||||||
if (i == live_objects->end()) {
|
if (i == live_objects->end()) {
|
||||||
std::cerr << "Attempting to delete " << ptr << " a non-living " << cls_name
|
warning_(_("Attempting to delete %1 a non-living %2") << ptr << cls_name);
|
||||||
<< std::endl;
|
|
||||||
memory_tracing_active = true;
|
memory_tracing_active = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -316,8 +315,7 @@ void trace_dtor_func(void * ptr, const char * cls_name, std::size_t cls_size)
|
||||||
|
|
||||||
object_count_map::iterator k = live_object_count->find(cls_name);
|
object_count_map::iterator k = live_object_count->find(cls_name);
|
||||||
if (k == live_object_count->end()) {
|
if (k == live_object_count->end()) {
|
||||||
std::cerr << "Failed to find " << cls_name << " in live object counts"
|
warning_(_("Failed to find %1 in live object counts") << cls_name);
|
||||||
<< std::endl;
|
|
||||||
memory_tracing_active = true;
|
memory_tracing_active = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue