## Copyright (C) 2016 Andrew Thornton ## ## This file is part of Octave. ## ## Octave is free software; you can redistribute it and/or modify it ## under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 3 of the License, or (at ## your option) any later version. ## ## Octave is distributed in the hope that it will be useful, but ## WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ## General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with Octave; see the file COPYING. If not, see ## . ## -*- texinfo -*- ## @deftypefn {} {@var{report} =} getReport(@var{ME}) ## @deftypefnx {} {@var{report} =} getReport(@var{ME}, @var{TYPE}) ## Get error messsage for exception ## ## The argument @var{ME} must be an exception. ## Argument @var{TYPE} can be either 'basic' or 'extended' and defaults to extended. ## @end deftypefn ## Author: Andrew Thornton ## Created: December 2015 function report = getReport(ME, TYPE, varargin) if ~exist('TYPE', 'var') TYPE = 'extended'; end if strcmpi(TYPE, 'basic') report = [ME.message]; elseif (length(ME.stack) == 1) report = strvcat( ['Error using ' ME.stack(1).name ' (line ' num2str(ME.stack(1).line) ')'], ... [ME.message]); else msg = @(x) {['Error in ' x.name ' (line ' num2str(x.line) ')']}; report = strvcat(... ME.message, ... arrayfun(msg, ME.stack){:}); end end