*** empty log message ***
This commit is contained in:
parent
e32d9e64a7
commit
bdd0dcf39d
2 changed files with 132 additions and 4 deletions
13
NEWS
13
NEWS
|
|
@ -1,7 +1,10 @@
|
|||
|
||||
Ledger NEWS
|
||||
|
||||
* 2.5
|
||||
* 2.6
|
||||
|
||||
- Error reporting has been greatly improving, now showing full
|
||||
contextual information for most error messages.
|
||||
|
||||
- Add a new --only predicate, which occurs during transaction
|
||||
processing between --limit and --display. Here is a summary of how
|
||||
|
|
@ -124,9 +127,6 @@
|
|||
|
||||
- Added new min(x,y) and max(x,y) value expression functions.
|
||||
|
||||
- Added a new value expression regexp command:
|
||||
C// compare against a transaction amount's commodity symbol
|
||||
|
||||
- Value expression function may now be defined within your ledger file
|
||||
(or initialization file) using the following syntax:
|
||||
|
||||
|
|
@ -136,6 +136,11 @@
|
|||
expressions, to all command-line options taking a value expression,
|
||||
and to the new "expr" command (see above).
|
||||
|
||||
* 2.5
|
||||
|
||||
- Added a new value expression regexp command:
|
||||
C// compare against a transaction amount's commodity symbol
|
||||
|
||||
- Added a new "csv" command, for outputting results in CSV format.
|
||||
|
||||
- Effective dates may now be specified for entries:
|
||||
|
|
|
|||
123
error.cc
Normal file
123
error.cc
Normal file
|
|
@ -0,0 +1,123 @@
|
|||
#include "error.h"
|
||||
#include "value.h"
|
||||
#include "valexpr.h"
|
||||
#include "format.h"
|
||||
#include "journal.h"
|
||||
|
||||
value_context::value_context(const ledger::value_t& _bal,
|
||||
const std::string& desc) throw()
|
||||
: bal(new ledger::value_t(_bal)), error_context(desc) {}
|
||||
|
||||
value_context::~value_context() throw()
|
||||
{
|
||||
delete bal;
|
||||
}
|
||||
|
||||
void value_context::describe(std::ostream& out) const throw()
|
||||
{
|
||||
if (! desc.empty())
|
||||
out << desc << std::endl;
|
||||
|
||||
ledger::balance_t * ptr = NULL;
|
||||
|
||||
out << std::right;
|
||||
out.width(20);
|
||||
|
||||
switch (bal->type) {
|
||||
case ledger::value_t::BOOLEAN:
|
||||
out << (*((bool *) bal->data) ? "true" : "false");
|
||||
break;
|
||||
case ledger::value_t::INTEGER:
|
||||
out << *((long *) bal->data);
|
||||
break;
|
||||
case ledger::value_t::DATETIME:
|
||||
out << *((datetime_t *) bal->data);
|
||||
break;
|
||||
case ledger::value_t::AMOUNT:
|
||||
out << *((ledger::amount_t *) bal->data);
|
||||
break;
|
||||
case ledger::value_t::BALANCE:
|
||||
ptr = (ledger::balance_t *) bal->data;
|
||||
// fall through...
|
||||
|
||||
case ledger::value_t::BALANCE_PAIR:
|
||||
if (! ptr)
|
||||
ptr = &((ledger::balance_pair_t *) bal->data)->quantity;
|
||||
|
||||
ptr->write(out, 20);
|
||||
break;
|
||||
default:
|
||||
assert(0);
|
||||
break;
|
||||
}
|
||||
out << std::endl;
|
||||
}
|
||||
|
||||
valexpr_context::valexpr_context(const ledger::value_expr_t * _expr,
|
||||
const std::string& desc) throw()
|
||||
: expr(NULL), error_node(_expr), error_context(desc)
|
||||
{
|
||||
error_node->acquire();
|
||||
}
|
||||
|
||||
valexpr_context::~valexpr_context() throw()
|
||||
{
|
||||
if (expr) expr->release();
|
||||
if (error_node) error_node->release();
|
||||
}
|
||||
|
||||
void valexpr_context::describe(std::ostream& out) const throw()
|
||||
{
|
||||
if (! expr) {
|
||||
out << "Valexpr_context expr not set!" << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
if (! desc.empty())
|
||||
out << desc << std::endl;
|
||||
|
||||
out << " ";
|
||||
unsigned long start = out.tellp();
|
||||
unsigned long pos = ledger::write_value_expr(out, expr,
|
||||
error_node, start);
|
||||
out << std::endl << " ";
|
||||
for (int i = 0; i < pos - start; i++)
|
||||
out << " ";
|
||||
out << "^" << std::endl;
|
||||
}
|
||||
|
||||
void line_context::describe(std::ostream& out) const throw()
|
||||
{
|
||||
if (! desc.empty())
|
||||
out << desc << std::endl;
|
||||
|
||||
out << " " << line << std::endl << " ";
|
||||
long idx = pos < 0 ? line.length() - 1 : pos;
|
||||
for (int i = 0; i < idx; i++)
|
||||
out << " ";
|
||||
out << "^" << std::endl;
|
||||
}
|
||||
|
||||
void entry_context::describe(std::ostream& out) const throw()
|
||||
{
|
||||
if (! desc.empty())
|
||||
out << desc << std::endl;
|
||||
|
||||
ledger::print_entry(out, entry, " ");
|
||||
}
|
||||
|
||||
xact_context::xact_context(const ledger::transaction_t& _xact,
|
||||
const std::string& desc) throw()
|
||||
: xact(_xact), file_context("", 0, desc)
|
||||
{
|
||||
const ledger::strings_list& sources(xact.entry->journal->sources);
|
||||
int x = 0;
|
||||
for (ledger::strings_list::const_iterator i = sources.begin();
|
||||
i != sources.end();
|
||||
i++, x++)
|
||||
if (x == xact.entry->src_idx) {
|
||||
file = *i;
|
||||
break;
|
||||
}
|
||||
line = xact.beg_line;
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue