Mercurial > hg > octave-nkf
diff libinterp/octave-value/ov-base.cc @ 20794:e5986cba4ca8
new octave_value::cell_value method with optional error message
* ov.h, ov.cc (octave_value::cell_value): New method.
* ov-base.h, ov-base.cc (octave_base_value::cell_value):
New default method.
* ov-cell.h, ov-cell.cc (octave_cell::cell_value): New method.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Fri, 09 Oct 2015 14:41:49 -0400 |
parents | 40ed9b46a800 |
children |
line wrap: on
line diff
--- a/libinterp/octave-value/ov-base.cc +++ b/libinterp/octave-value/ov-base.cc @@ -537,6 +537,33 @@ return retval; } +Cell +octave_base_value::cell_value (const char *fmt, va_list args) const +{ + // Note that this method does not need to be particularly efficient + // since it is already an error to end up here. + + // FIXME: do we want both the wrong-type-argument error and any custom + // error message, or just the custom error message, or should that + // behavior be optional in some way? + + try + { + std::string tn = type_name (); + + error ("wrong type argument '%s'\n", tn.c_str ()); + } + catch (const octave_execution_exception&) + { + if (fmt) + verror (fmt, args); + + throw; + } + + return Cell (); +} + Matrix octave_base_value::matrix_value (bool) const {