1function line_error(caller, msg, varargin)
2%LINE_ERROR Display a plain-text error message with file and line info.
4% LINE_ERROR(CALLER, MSG, ...) throws an error with CALLER's name and
5% message, including the source file and line number, in plain text (no
6% hyperlink). Extra arguments are passed to sprintf to format MSG.
8% Copyright (c) 2012-2026, Imperial College London
11if coder.target('MATLAB')
13 msg = sprintf(msg, varargin{:});
16 msg = strrep(msg,
'\n',
''); % Strip out literal
'\n' if present
20 lineNum = stack(2).line;
25 filePath = which(caller);
30 errStr = sprintf(
'[%s.m @ line %d] %s', caller, lineNum, msg);
37 error(
'%s: %s', caller, msg);