MatrixBerryCore
MExceptionUtils.m
Go to the documentation of this file.
1 classdef MExceptionUtils
2  methods (Static)
3  [fullErrMsgStr,errMsgStr,stackTraceStr]=me2PlainString(meObj)
4  [fullErrMsgStr,errMsgStr,stackTraceStr]=me2HyperString(meObj)
5  [fullErrMsgStr,errMsgStr,stackTraceStr]=me2String(meObj,varargin)
6  %
7  varargout=me2ErrStackStrings(meObj,varargin)
8  %
9  stackTraceStr = meStack2PlainString(StackVec,varargin)
10  stackTraceStr = meStack2HyperString(StackVec,varargin)
11  stackTraceStr = meStack2String(StackVec,varargin)
12  end
13  %
14  methods (Access=private,Static)
15  %
16  function [errStr, stackStr] = parseMeErrorMessage(meObj,varargin)
17  errStr=['message:[',meObj.message '], identifier:[',meObj.identifier,']'];
18  %
19  if nargout>1
20  REF_AS_ERR_MSG_REG_EXP=['Error: <a.*opentoline\(''(.*)'',\d+,\d+\).*',...
21  'File:\ ([\w\ \.,$&/\\:@]*.m)\ Line: (\w*)\ Column: (\w*)\s*</a>\n*(.*)'];
22  StackVec=meObj.stack;
23  %
24  tokens = regexp(errStr,REF_AS_ERR_MSG_REG_EXP,'tokens','once');
25  if ~isempty(tokens)
26  fullFileName=tokens{1};
27  shortFileName=tokens{2};
28  lineNumber=tokens{3};
29  errStr=tokens{5};
30  StackEntry=struct('file',fullFileName,'name',shortFileName,...
31  'line',str2double(lineNumber));
32  StackVec=[StackEntry;StackVec];
33  else
34  [tokens] = regexp(errStr,...
35  'Error using ==> <a href.*>(.*)</a>\n(.*)', 'tokens', 'once');
36  if (length(tokens) == 2)
37  errStr = char(tokens(2));
38  end
39  end
40  stackStr=mxberry.core.MExceptionUtils.meStack2String(...
41  StackVec,varargin{:});
42  end
43  end
44  end
45 end