Commit e1dfec17 authored by Houtan Bastani's avatar Houtan Bastani

add more helpful error messages. closes #6

parent 7628cdad
......@@ -12,7 +12,7 @@ function o = addGraph(o, varargin)
% SPECIAL REQUIREMENTS
% none
% Copyright (C) 2013-2014 Dynare Team
% Copyright (C) 2013-2015 Dynare Team
%
% This file is part of Dynare.
%
......@@ -29,6 +29,10 @@ function o = addGraph(o, varargin)
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
assert(length(o.pages) > 0, ...
'@report.addGraph: Before adding a graph, you must add a page and a section.');
assert(length(o.pages{end}.sections) > 0, ...
'@report.addGraph: Before adding a graph, you must add a section.');
o.pages{end}.sections{end} = ...
o.pages{end}.sections{end}.addGraph(varargin{:});
end
......@@ -12,7 +12,7 @@ function o = addParagraph(o, varargin)
% SPECIAL REQUIREMENTS
% none
% Copyright (C) 2013-2014 Dynare Team
% Copyright (C) 2013-2015 Dynare Team
%
% This file is part of Dynare.
%
......@@ -29,6 +29,10 @@ function o = addParagraph(o, varargin)
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
assert(length(o.pages) > 0, ...
'@report.addParagraph: Before adding a paragraph, you must add a page and a section.');
assert(length(o.pages{end}.sections) > 0, ...
'@report.addParagraph: Before adding a paragraph, you must add a section.');
o.pages{end}.sections{end} = ...
o.pages{end}.sections{end}.addParagraph(varargin{:});
end
......@@ -12,7 +12,7 @@ function o = addSection(o, varargin)
% SPECIAL REQUIREMENTS
% none
% Copyright (C) 2013-2014 Dynare Team
% Copyright (C) 2013-2015 Dynare Team
%
% This file is part of Dynare.
%
......@@ -29,5 +29,7 @@ function o = addSection(o, varargin)
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
assert(length(o.pages) > 0, ...
'@report.addSection: Before adding a section, you must add a page.');
o.pages{end} = o.pages{end}.addSection(varargin{:});
end
......@@ -12,7 +12,7 @@ function o = addSeries(o, varargin)
% SPECIAL REQUIREMENTS
% none
% Copyright (C) 2013-2014 Dynare Team
% Copyright (C) 2013-2015 Dynare Team
%
% This file is part of Dynare.
%
......@@ -29,6 +29,15 @@ function o = addSeries(o, varargin)
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
assert(length(o.pages) > 0, ...
['@report.addSeries: Before adding a series, you must add a page, ' ...
'section, and either a graph or a table.']);
assert(length(o.pages{end}.sections) > 0, ...
['@report.addSeries: Before adding a series, you must add a section and ' ...
'either a graph or a table']);
assert(length(o.pages{end}.sections.elements) > 0, ...
['@report.addSeries: Before adding a series, you must add ' ...
'either a graph or a table']);
assert(isa(o.pages{end}.sections{end}.elements{end}, 'graph') || ...
isa(o.pages{end}.sections{end}.elements{end}, 'report_table'), ...
'@report.addSeries: you can only add a series to a report_table or graph object');
......
......@@ -12,7 +12,7 @@ function o = addTable(o, varargin)
% SPECIAL REQUIREMENTS
% none
% Copyright (C) 2013-2014 Dynare Team
% Copyright (C) 2013-2015 Dynare Team
%
% This file is part of Dynare.
%
......@@ -29,6 +29,10 @@ function o = addTable(o, varargin)
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
assert(length(o.pages) > 0, ...
'@report.addTable: Before adding a table, you must add a page and a section.');
assert(length(o.pages{end}.sections) > 0, ...
'@report.addTable: Before adding a table, you must add a section.');
o.pages{end}.sections{end} = ...
o.pages{end}.sections{end}.addTable(varargin{:});
end
......@@ -12,7 +12,7 @@ function o = addVspace(o, varargin)
% SPECIAL REQUIREMENTS
% none
% Copyright (C) 2013-2014 Dynare Team
% Copyright (C) 2013-2015 Dynare Team
%
% This file is part of Dynare.
%
......@@ -29,6 +29,10 @@ function o = addVspace(o, varargin)
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
assert(length(o.pages) > 0, ...
'@report.addVspace: Before adding a vspace, you must add a page and a section.');
assert(length(o.pages{end}.sections) > 0, ...
'@report.addVspace: Before adding a vspace, you must add a section.');
o.pages{end}.sections{end} = ...
o.pages{end}.sections{end}.addVspace(varargin{:});
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment