1function mexErrCheck(mexFunctionName, err)
2% function mexErrCheck(mexFunctionName, err)
3% this function halts processing if err is equal to 1.
4%
5% INPUTS
6%   mexFunctionName [char]    Name of the mexFunction
7%   err             [double]  error code returned from mexFunction
8%
9% OUTPUTS
10%   none.
11%
12% ALGORITHM
13%   ...
14%
15% SPECIAL REQUIREMENTS
16%   none.
17%
18
19% Copyright (C) 2010 Dynare Team
20%
21% This file is part of Dynare.
22%
23% Dynare is free software: you can redistribute it and/or modify
24% it under the terms of the GNU General Public License as published by
25% the Free Software Foundation, either version 3 of the License, or
26% (at your option) any later version.
27%
28% Dynare is distributed in the hope that it will be useful,
29% but WITHOUT ANY WARRANTY; without even the implied warranty of
30% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
31% GNU General Public License for more details.
32%
33% You should have received a copy of the GNU General Public License
34% along with Dynare.  If not, see <http://www.gnu.org/licenses/>.
35
36if ~ischar(mexFunctionName) || ~isscalar(err)
37    error('The first argument must be a char and the second a scalar');
38end
39
40if err
41    error(['Error encountered in: ' mexFunctionName '.']);
42end