Main Content

getReport

예외(Exception)에 대한 오류 메시지 가져오기

설명

예제

msgText = getReport(exception)은 예외에 대한 오류 메시지를 가져와서 이를 서식 지정된 텍스트 msgText로 반환합니다. 메시지는 MException 객체인 exceptionmessage 속성값입니다. 텍스트는 MATLAB®이 예외를 발생시킬 때 표시하는 텍스트와 동일합니다.

예제

msgText = getReport(exception,type)type으로 지정된 상세 수준에 따라 오류 메시지를 반환합니다.

예제

msgText = getReport(exception,type,'hyperlinks',hlink)hlink 값을 사용하여, 오류 메시지 내 오류가 발생한 코드 라인에 활성 하이퍼링크를 포함시킬지 여부를 지정합니다.

예제

모두 축소

MATLAB에서 예외가 발생하도록 합니다.

plus
Error using +
Not enough input arguments.

예외에서 오류 메시지를 가져옵니다.

exception = MException.last;
msgText = getReport(exception)
msgText =

Error using +
Not enough input arguments.

현재 작업 폴더에 있는 파일 testFunc.m에 다음 함수를 만듭니다.

function a = testFunc
try
    a = notaFunction(5,6);
catch a

end

함수 notaFunction은 존재하지 않으므로 testFuncMException 객체를 반환합니다.

명령 프롬프트에서 testFunc를 호출하고 오류 메시지를 표시합니다.

m = testFunc;
msgText = getReport(m)
msgText =

Undefined function 'notaFunction' for input arguments of type 'double'.

Error in testFunc (line 3)
    a = notaFunction(5,6);

오류 메시지에 오류 메시지만 포함되고 스택 정보는 포함되지 않도록 지정합니다.

msgText = getReport(m,'basic')
msgText =

Undefined function 'notaFunction' for input arguments of type 'double'.

MATLAB에서 예외가 발생하도록 합니다.

try 
    surf
catch exception
end

예외에서 오류 메시지를 가져옵니다.

msgText = getReport(exception)
msgText =

Error using surf (line 49)
Not enough input arguments.

surf.m에 대한 활성 하이퍼링크를 제외하고 오류 메시지를 가져옵니다.

msgText = getReport(exception,'extended','hyperlinks','off')
msgText =

Error using surf (line 49)
Not enough input arguments.

입력 인수

모두 축소

오류 메시지를 제공하는 예외 객체로, 스칼라 MException 객체로 지정됩니다.

반환할 메시지의 상세 수준 표시자로, 'extended''basic'으로 지정됩니다.

typemsgText 상세 수준
'extended'(디폴트 값)msgText에는 라인 번호, 오류 메시지, 원인, 스택 요약이 포함됩니다. 적절한 스택을 표시하려면 MATLAB이 먼저 예외를 발생시켜야 합니다.
'basic'msgText에는 오류 메시지가 포함됩니다.

확장 기능

스레드 기반 환경
MATLAB®의 backgroundPool을 사용해 백그라운드에서 코드를 실행하거나 Parallel Computing Toolbox™의 ThreadPool을 사용해 코드 실행 속도를 높일 수 있습니다.

버전 내역

R2007b에 개발됨

참고 항목

| |