www.gusucode.com > mbcmodels 工具箱 matlab 源码程序 > mbcmodels/@xregusermod/ReportError.m

    function ReportError(U,ME)
%REPORTERROR report error to command-line
%
% ReportError(U,ME)
%    ME is an MException object

%  Copyright 2007 The MathWorks, Inc. and Ford Global Technologies, Inc.

if U.ThrowError
    rethrow(ME)
else
    printLine = @( s ) fprintf( ...
        'In <a href="matlab:opentoline( ''%s'', %d )">%s at %d</a>\n', ...
        s.file, s.line, functionName( s.file, s.name ), s.line );

    fprintf( 'MBC Diagnostic: Error in %s model "%s".\n   %s\n', getType(U), name(U), ME.message );
    if ~strcmp(ME.identifier,'MATLAB:UndefinedFunction') || isempty(strfind(ME.message,'''i_'))
        printLine( ME.stack(1) );
    else
        fprintf('%s\n',ME.message)
    end
end

function f = functionName( funcPath, func )
[junk, funcFile] = fileparts( funcPath );
if strcmpi( funcFile, func ),
    f = func;
else
    f = sprintf( '%s>%s', funcFile, func );
end