From fbf807ad0f112a075d11eb641735e3cfef69057c Mon Sep 17 00:00:00 2001 From: Houtan Bastani <houtan@dynare.org> Date: Fri, 8 Mar 2013 19:25:24 +0100 Subject: [PATCH] reporting: make errors more clear --- matlab/reporting/@elements/elements.m | 6 +++--- matlab/reporting/@elements/subsasgn.m | 2 +- matlab/reporting/@elements/subsref.m | 6 +++--- matlab/reporting/@graph/createGraph.m | 9 ++++++--- matlab/reporting/@graph/graph.m | 9 ++++----- matlab/reporting/@graph/subsasgn.m | 4 ++-- matlab/reporting/@graph/subsref.m | 6 +++--- matlab/reporting/@objArray/getObjs.m | 2 +- matlab/reporting/@objArray/objArray.m | 4 ++-- matlab/reporting/@objArray/subsasgn.m | 2 +- matlab/reporting/@objArray/subsref.m | 6 +++--- matlab/reporting/@page/page.m | 9 ++++----- matlab/reporting/@page/subsasgn.m | 4 ++-- matlab/reporting/@page/subsref.m | 6 +++--- matlab/reporting/@pages/pages.m | 6 +++--- matlab/reporting/@pages/subsasgn.m | 2 +- matlab/reporting/@pages/subsref.m | 6 +++--- matlab/reporting/@report/report.m | 8 ++++---- matlab/reporting/@report/subsasgn.m | 4 ++-- matlab/reporting/@report/subsref.m | 6 +++--- matlab/reporting/@report/write.m | 4 ++-- matlab/reporting/@section/section.m | 6 +++--- matlab/reporting/@section/subsasgn.m | 2 +- matlab/reporting/@section/subsref.m | 6 +++--- matlab/reporting/@sections/sections.m | 2 +- matlab/reporting/@sections/subsasgn.m | 2 +- matlab/reporting/@sections/subsref.m | 6 +++--- matlab/reporting/@table/subsasgn.m | 4 ++-- matlab/reporting/@table/subsref.m | 6 +++--- 29 files changed, 73 insertions(+), 72 deletions(-) diff --git a/matlab/reporting/@elements/elements.m b/matlab/reporting/@elements/elements.m index e6ca1a3152..77c3f91d7f 100644 --- a/matlab/reporting/@elements/elements.m +++ b/matlab/reporting/@elements/elements.m @@ -33,10 +33,10 @@ switch nargin e = class(struct, 'elements', objArray()); case 1 assert(isa(varargin{1}, 'elements'), ... - ['With one arg to elements constructor, you must pass an ' ... - 'elements object or a char.']); + ['@elements.elements: with one arg, you must pass an elements ' ... + 'object or a char.']); e = varargin{1}; otherwise - error('Elements constructor: invalid number of arguments'); + error('@elements.elements: invalid number of arguments'); end end \ No newline at end of file diff --git a/matlab/reporting/@elements/subsasgn.m b/matlab/reporting/@elements/subsasgn.m index 878a5ee152..5661f66e4a 100644 --- a/matlab/reporting/@elements/subsasgn.m +++ b/matlab/reporting/@elements/subsasgn.m @@ -34,6 +34,6 @@ switch S.type assert(isnumeric(index)); B.objArray(index) = V; otherwise - error('Elements subsasign syntax error') + error('@elements.subsasign: syntax error'); end end \ No newline at end of file diff --git a/matlab/reporting/@elements/subsref.m b/matlab/reporting/@elements/subsref.m index d1dac4c8a3..0562000bc4 100644 --- a/matlab/reporting/@elements/subsref.m +++ b/matlab/reporting/@elements/subsref.m @@ -31,14 +31,14 @@ switch S(1).type A = feval(S(1).subs, A); end otherwise - error(['Elements Class: unknown field or method: ' S(1).subs]); + error(['@elements.subsref: unknown field or method: ' S(1).subs]); end case '()' A = getElements(A, S(1).subs{:}); case '{}' - error(['Elements Class: ' S(1).type ' indexing not supported.']); + error(['@elements.subsref: ' S(1).type ' indexing not supported.']); otherwise - error('Elements Class: subsref.m impossible case') + error('@elements.subsref: impossible case'); end S = shiftS(S); diff --git a/matlab/reporting/@graph/createGraph.m b/matlab/reporting/@graph/createGraph.m index 696a93df6b..d2c663db25 100644 --- a/matlab/reporting/@graph/createGraph.m +++ b/matlab/reporting/@graph/createGraph.m @@ -32,7 +32,8 @@ assert(~isempty(o.data)); assert(isa(o.data, 'dynSeries')) ; if ~isempty(o.figname) - warning('Will overwrite %s with new graph\n', o.figname); + warning('@graph.createGraph: will overwrite %s with new graph\n', ... + o.figname); end %o = readConfig(o); @@ -66,10 +67,12 @@ if ~isempty(o.shade) yrange = get(gca, 'YLim'); if isempty(x1) - error([o.shade{1} ' not in date range of provided data']); + error(['@graph.createGraph: ' o.shade{1} ' not in date range of ' ... + 'provided data']); end if isempty(x2) - error([o.shade{2} ' not in date range of provided data']); + error(['@graph.createGraph: ' o.shade{2} ' not in date range of ' ... + 'provided data']); end % From ShadePlotForEmpahsis (Matlab Exchange) diff --git a/matlab/reporting/@graph/graph.m b/matlab/reporting/@graph/graph.m index 759df6fe9f..b8a73374e4 100644 --- a/matlab/reporting/@graph/graph.m +++ b/matlab/reporting/@graph/graph.m @@ -52,13 +52,13 @@ o.legend_orientation = 'horizontal'; o.legend_font_size = 8; if nargin == 1 - assert(isa(varargin{1}, 'graph'),['With one arg to Graph constructor, ' ... - 'you must pass a graph object']); + assert(isa(varargin{1}, 'graph'),['@graph.graph: with one arg you ' ... + 'must pass a graph object']); o = varargin{1}; return; elseif nargin > 1 if round(nargin/2) ~= nargin/2 - error(['Options to Graph constructor must be supplied in name/value ' ... + error(['@graph.graph: options must be supplied in name/value ' ... 'pairs.']); end @@ -70,8 +70,7 @@ elseif nargin > 1 if any(strmatch(field, optNames, 'exact')) o.(field) = pair{2}; else - error('%s is not a recognized option to the Graph constructor.', ... - field); + error('@graph.graph: %s is not a recognized option.', field); end end end diff --git a/matlab/reporting/@graph/subsasgn.m b/matlab/reporting/@graph/subsasgn.m index deef33b820..8ab064094a 100644 --- a/matlab/reporting/@graph/subsasgn.m +++ b/matlab/reporting/@graph/subsasgn.m @@ -34,9 +34,9 @@ switch S.type case fieldnames(A) B.(S.subs) = V; otherwise - error(['field ' S.subs 'does not exist in the page class']) + error(['@graph.subsasgn: field ' S.subs 'does not exist']); end otherwise - error('report subsasign syntax error') + error('@graph.subsasgn: syntax error'); end end \ No newline at end of file diff --git a/matlab/reporting/@graph/subsref.m b/matlab/reporting/@graph/subsref.m index 01a57c6eb4..1610116f77 100644 --- a/matlab/reporting/@graph/subsref.m +++ b/matlab/reporting/@graph/subsref.m @@ -31,12 +31,12 @@ switch S(1).type A = feval(S(1).subs, A); end otherwise - error(['Graph Class: unknown field or method: ' S(1).subs]); + error(['@graph.subsref: unknown field or method: ' S(1).subs]); end case {'()', '{}'} - error(['Graph Class: ' S(1).type ' indexing not supported.']); + error(['@graph.subsref: ' S(1).type ' indexing not supported.']); otherwise - error('Graph Class: subsref.m impossible case') + error('@graph.subsref: impossible case') end S = shiftS(S); diff --git a/matlab/reporting/@objArray/getObjs.m b/matlab/reporting/@objArray/getObjs.m index 6c7dcbeae9..a3b239a4a2 100644 --- a/matlab/reporting/@objArray/getObjs.m +++ b/matlab/reporting/@objArray/getObjs.m @@ -25,6 +25,6 @@ switch nargin assert(isnumeric(varargin{1})); e = oa.objs{varargin{1}}; otherwise - error('objArray getObjs: invalid number of arguments'); + error('@objArray.getObjs: invalid number of arguments'); end end \ No newline at end of file diff --git a/matlab/reporting/@objArray/objArray.m b/matlab/reporting/@objArray/objArray.m index 5ac61e7097..4f0dff92f5 100644 --- a/matlab/reporting/@objArray/objArray.m +++ b/matlab/reporting/@objArray/objArray.m @@ -34,10 +34,10 @@ switch nargin oa.objs = cell(0); oa = class(oa, 'objArray'); case 1 - assert(isa(varargin{1}, 'objArray'), ['ObjArray constructor: the only ' ... + assert(isa(varargin{1}, 'objArray'), ['@objArray.objArray: the only ' ... 'valid arguments are objArray objects']); oa = varargin{1}; otherwise - error('ObjArray constructor: invalid number of arguments'); + error('@objArray.objArray: invalid number of arguments'); end end \ No newline at end of file diff --git a/matlab/reporting/@objArray/subsasgn.m b/matlab/reporting/@objArray/subsasgn.m index b1777ab1f2..6cc07616db 100644 --- a/matlab/reporting/@objArray/subsasgn.m +++ b/matlab/reporting/@objArray/subsasgn.m @@ -34,6 +34,6 @@ switch S.type assert(isnumeric(index)); B.objs{index} = V; otherwise - error('objArray subsasgn syntax error') + error('objArray.subsasgn: syntax error'); end end \ No newline at end of file diff --git a/matlab/reporting/@objArray/subsref.m b/matlab/reporting/@objArray/subsref.m index f5e15e6907..81d75b09c9 100644 --- a/matlab/reporting/@objArray/subsref.m +++ b/matlab/reporting/@objArray/subsref.m @@ -31,14 +31,14 @@ switch S(1).type A = feval(S(1).subs, A); end otherwise - error(['ObjArray Class: unknown field or method: ' S(1).subs]); + error(['objArray.subsref: unknown field or method: ' S(1).subs]); end case '()' A = getObjs(A, S(1).subs{:}); case '{}' - error(['ObjArray Class: ' S(1).type ' indexing not supported.']); + error(['objArray.subsref: ' S(1).type ' indexing not supported.']); otherwise - error('ObjArray Class: subsref.m impossible case') + error('objArray.subsref: impossible case') end S = shiftS(S); diff --git a/matlab/reporting/@page/page.m b/matlab/reporting/@page/page.m index d0dd38caef..5882b518d8 100644 --- a/matlab/reporting/@page/page.m +++ b/matlab/reporting/@page/page.m @@ -37,13 +37,13 @@ o.footnote = ''; o.sections = sections(); if nargin == 1 - assert(isa(varargin{1}, 'page'), ['With one arg to Page constructor, ' ... - 'you must pass a page object']); + assert(isa(varargin{1}, 'page'), ['@page.page: with one arg to Page ' ... + 'constructor, you must pass a page object']); o = varargin{1}; return; elseif nargin > 1 if round(nargin/2) ~= nargin/2 - error(['Options to Page constructor must be supplied in name/value ' ... + error(['@page.page: options must be supplied in name/value ' ... 'pairs.']); end @@ -55,8 +55,7 @@ elseif nargin > 1 if any(strmatch(field, optNames, 'exact')) o.(field) = pair{2}; else - error('%s is not a recognized option to the Page constructor.', ... - field); + error('@page.page: %s is not a recognized option.', field); end end end diff --git a/matlab/reporting/@page/subsasgn.m b/matlab/reporting/@page/subsasgn.m index ede173bfbf..00e85ae2d3 100644 --- a/matlab/reporting/@page/subsasgn.m +++ b/matlab/reporting/@page/subsasgn.m @@ -38,9 +38,9 @@ switch S.type case fieldnames(A) B.(S.subs) = V; otherwise - error(['field ' S.subs 'does not exist in the page class']) + error(['@page.subsasgn: field ' S.subs 'does not exist']); end otherwise - error('report subsasign syntax error') + error('@page.subsasgn: syntax error'); end end \ No newline at end of file diff --git a/matlab/reporting/@page/subsref.m b/matlab/reporting/@page/subsref.m index 7b3826bb94..3b58fddc80 100644 --- a/matlab/reporting/@page/subsref.m +++ b/matlab/reporting/@page/subsref.m @@ -31,14 +31,14 @@ switch S(1).type A = feval(S(1).subs, A); end otherwise - error(['Page Class: unknown field or method: ' S(1).subs]); + error(['@page.subsref: unknown field or method: ' S(1).subs]); end case '()' A = getSections(A, S(1).subs{:}); case '{}' - error(['Page Class: ' S(1).type ' indexing not supported.']); + error(['@page.subsref: ' S(1).type ' indexing not supported.']); otherwise - error('Page Class: subsref.m impossible case') + error('@page.subsref: impossible case') end S = shiftS(S); diff --git a/matlab/reporting/@pages/pages.m b/matlab/reporting/@pages/pages.m index 189ab2d7dc..37727eb94c 100644 --- a/matlab/reporting/@pages/pages.m +++ b/matlab/reporting/@pages/pages.m @@ -33,10 +33,10 @@ switch nargin ps = class(struct, 'pages', objArray()); case 1 assert(isa(varargin{1}, 'pages'), ... - ['With one arg to pages constructor, you must pass an ' ... - 'pages object or a char.']); + ['@pages.pages: With one arg to pages constructor, you must ' ... + 'pass an pages object or a char.']); ps = varargin{1}; otherwise - error('Pages constructor: invalid number of arguments'); + error('@pages.pages: invalid number of arguments'); end end \ No newline at end of file diff --git a/matlab/reporting/@pages/subsasgn.m b/matlab/reporting/@pages/subsasgn.m index d99e0695f9..318b0bd826 100644 --- a/matlab/reporting/@pages/subsasgn.m +++ b/matlab/reporting/@pages/subsasgn.m @@ -34,6 +34,6 @@ switch S.type assert(isnumeric(index)); B.objArray(index) = V; otherwise - error('Pages subsasign syntax error'); + error('@pages.subsasgn: syntax error'); end end \ No newline at end of file diff --git a/matlab/reporting/@pages/subsref.m b/matlab/reporting/@pages/subsref.m index 8d78e5c263..643f218c19 100644 --- a/matlab/reporting/@pages/subsref.m +++ b/matlab/reporting/@pages/subsref.m @@ -31,14 +31,14 @@ switch S(1).type A = feval(S(1).subs, A); end otherwise - error(['Pages Class: unknown field or method: ' S(1).subs]); + error(['@pages.subsref: unknown field or method: ' S(1).subs]); end case '()' A = getPages(A, S(1).subs{:}); case '{}' - error(['Pages Class: ' S(1).type ' indexing not supported.']); + error(['@pages.subsref: ' S(1).type ' indexing not supported.']); otherwise - error('Pages Class: subsref.m impossible case') + error('@pages.subsref: impossible case') end S = shiftS(S); diff --git a/matlab/reporting/@report/report.m b/matlab/reporting/@report/report.m index 0fd4de327b..77f3faa909 100644 --- a/matlab/reporting/@report/report.m +++ b/matlab/reporting/@report/report.m @@ -41,14 +41,14 @@ o.config = ''; o.showdate = true; if nargin == 1 - assert(isa(varargin{1}, 'report'),['With one arg to Report constructor, ' ... + assert(isa(varargin{1}, 'report'), ['@report.report: with one arg, ' ... 'you must pass a report object']); r = varargin{1}; return; elseif nargin > 1 if round(nargin/2) ~= nargin/2 - error(['Options to Report constructor must be supplied in name/value ' ... - 'pairs.']); + error(['@report.report: options must be supplied in name/value ' ... + 'pairs']); end optNames = lower(fieldnames(o)); @@ -64,7 +64,7 @@ elseif nargin > 1 end o.(field) = pair{2}; else - error('%s is not a recognized option to the Report constructor.', ... + error('@report.report: %s is not a recognized option.', ... field); end end diff --git a/matlab/reporting/@report/subsasgn.m b/matlab/reporting/@report/subsasgn.m index 527e6c9059..60c7d969c2 100644 --- a/matlab/reporting/@report/subsasgn.m +++ b/matlab/reporting/@report/subsasgn.m @@ -38,9 +38,9 @@ switch S.type case fieldnames(A) B.(S.subs) = V; otherwise - error(['field ' S.subs 'does not exist in the report class']); + error(['@report.subsasgn: field ' S.subs 'does not exist']); end otherwise - error('report subsasign syntax error'); + error('@report.subsasgn: syntax error'); end end \ No newline at end of file diff --git a/matlab/reporting/@report/subsref.m b/matlab/reporting/@report/subsref.m index 9559393fe6..f8714054d7 100644 --- a/matlab/reporting/@report/subsref.m +++ b/matlab/reporting/@report/subsref.m @@ -31,14 +31,14 @@ switch S(1).type A = feval(S(1).subs, A); end otherwise - error(['Report Class: unknown field or method: ' S(1).subs]); + error(['@report.subsasgn: unknown field or method: ' S(1).subs]); end case '()' A = A.pages.getPages(S(1).subs{:}); case '{}' - error(['Report Class: ' S(1).type ' indexing not supported.']); + error(['@report.subsasgn: ' S(1).type ' indexing not supported.']); otherwise - error('Report Class: subsref.m impossible case'); + error('@report.subsasgn: impossible case'); end S = shiftS(S); diff --git a/matlab/reporting/@report/write.m b/matlab/reporting/@report/write.m index 456f58a76e..21496e2e99 100644 --- a/matlab/reporting/@report/write.m +++ b/matlab/reporting/@report/write.m @@ -30,7 +30,7 @@ function o = write(o) [fid, msg] = fopen(o.filename, 'w'); if fid == -1 - error(msg); + error(['@report.subsasgn: ' msg]); end fprintf(fid, '%% Report Object\n'); @@ -67,6 +67,6 @@ fprintf(fid, '\\end{document}\n'); fprintf(fid, '%% End Report Object\n'); status = fclose(fid); if status == -1 - error('Error closing %s\n', o.filename); + error('@report.wrie: closing %s\n', o.filename); end end \ No newline at end of file diff --git a/matlab/reporting/@section/section.m b/matlab/reporting/@section/section.m index e2260f47b2..2e3f0972bc 100644 --- a/matlab/reporting/@section/section.m +++ b/matlab/reporting/@section/section.m @@ -32,8 +32,8 @@ if nargin == 1 return; elseif nargin > 1 if round(nargin/2) ~= nargin/2 - error(['Options to Section constructor must be supplied in name/' ... - 'value pairs.']); + error(['@section.section: options must be supplied in name/value ' ... + 'pairs.']); end optNames = lower(fieldnames(o)); @@ -44,7 +44,7 @@ elseif nargin > 1 if any(strmatch(field, optNames, 'exact')) o.(field) = pair{2}; else - error('%s is not a recognized option to the Section constructor.', ... + error('@section.section: %s is not a recognized option.', ... field); end end diff --git a/matlab/reporting/@section/subsasgn.m b/matlab/reporting/@section/subsasgn.m index 3311423eed..79f3af53a1 100644 --- a/matlab/reporting/@section/subsasgn.m +++ b/matlab/reporting/@section/subsasgn.m @@ -34,6 +34,6 @@ switch S.type assert(isnumeric(index)); B(index) = V; otherwise - error('objArray subsasign syntax error') + error('@section.subsasgn: syntax error') end end \ No newline at end of file diff --git a/matlab/reporting/@section/subsref.m b/matlab/reporting/@section/subsref.m index eeb041c530..82994b82a7 100644 --- a/matlab/reporting/@section/subsref.m +++ b/matlab/reporting/@section/subsref.m @@ -31,14 +31,14 @@ switch S(1).type A = feval(S(1).subs, A); end otherwise - error(['Section Class: unknown field or method: ' S(1).subs]); + error(['@section.subsref: unknown field or method: ' S(1).subs]); end case '()' A = A.elements.getElements(S(1).subs{:}); case '{}' - error(['Section Class: ' S(1).type ' indexing not supported.']); + error(['@section.subsref: ' S(1).type ' indexing not supported.']); otherwise - error('Section Class: subsref.m impossible case') + error('@section.subsref: impossible case') end S = shiftS(S); diff --git a/matlab/reporting/@sections/sections.m b/matlab/reporting/@sections/sections.m index bacde01981..9779751fe0 100644 --- a/matlab/reporting/@sections/sections.m +++ b/matlab/reporting/@sections/sections.m @@ -26,7 +26,7 @@ switch nargin 'valid arguments are sections objects']); s = varargin{1}; otherwise - error('Sections constructor: invalid number of arguments'); + error('@sections.sections: invalid number of arguments'); end end diff --git a/matlab/reporting/@sections/subsasgn.m b/matlab/reporting/@sections/subsasgn.m index 1916c1a5c3..2782f7e1c7 100644 --- a/matlab/reporting/@sections/subsasgn.m +++ b/matlab/reporting/@sections/subsasgn.m @@ -34,6 +34,6 @@ switch S.type assert(isnumeric(index)); B.objArray(index) = V; otherwise - error('objArray subsasign syntax error') + error('@sections.subsasgn: syntax error') end end \ No newline at end of file diff --git a/matlab/reporting/@sections/subsref.m b/matlab/reporting/@sections/subsref.m index 89e2948f80..8661809acf 100644 --- a/matlab/reporting/@sections/subsref.m +++ b/matlab/reporting/@sections/subsref.m @@ -31,14 +31,14 @@ switch S(1).type A = feval(S(1).subs, A); end otherwise - error(['Sections Class: unknown field or method: ' S(1).subs]); + error(['@sections.subsref unknown field or method: ' S(1).subs]); end case '()' A = getSections(A, S(1).subs{:}); case '{}' - error(['Sections Class: ' S(1).type ' indexing not supported.']); + error(['@sections.subsref ' S(1).type ' indexing not supported.']); otherwise - error('Sections Class: subsref.m impossible case') + error('@sections.subsref subsref.m impossible case') end S = shiftS(S); diff --git a/matlab/reporting/@table/subsasgn.m b/matlab/reporting/@table/subsasgn.m index deef33b820..1b903e6ccc 100644 --- a/matlab/reporting/@table/subsasgn.m +++ b/matlab/reporting/@table/subsasgn.m @@ -34,9 +34,9 @@ switch S.type case fieldnames(A) B.(S.subs) = V; otherwise - error(['field ' S.subs 'does not exist in the page class']) + error(['@table.subsasgn: field ' S.subs 'does not exist in the table class']) end otherwise - error('report subsasign syntax error') + error('@table.subsasgn: syntax error') end end \ No newline at end of file diff --git a/matlab/reporting/@table/subsref.m b/matlab/reporting/@table/subsref.m index 1f9468edac..7062d72ff0 100644 --- a/matlab/reporting/@table/subsref.m +++ b/matlab/reporting/@table/subsref.m @@ -31,12 +31,12 @@ switch S(1).type A = feval(S(1).subs, A); end otherwise - error(['Table Class: unknown field or method: ' S(1).subs]); + error(['@table.subsref: unknown field or method: ' S(1).subs]); end case {'()', '{}'} - error(['Table Class: ' S(1).type ' indexing not supported.']); + error(['@table.subsref: ' S(1).type ' indexing not supported.']); otherwise - error('Table Class: subsref.m impossible case') + error('@table.subsref: subsref.m impossible case') end S = shiftS(S); -- GitLab