Custom error message for exceptions

7 次查看(过去 30 天)
Francisco
Francisco 2012-2-9
This is the situation:
I want to throw an MException with a custom message, lets say:
if(0 == this.Model.NumInputs)
err = MException('jku.methods:InvalidModel', 'Invalid Tree. The prune of the tree gives an empty tree!');
throw(err);
end
How can I define that message identifier 'jku.methods:InvalidModel' ??? I am getting the error
??? Error using ==> MException IDENTIFIER input must be a valid MATLAB message identifier. For more information, search for "message identifier" in the MATLAB Help.
Thanks !!

回答(1 个)

Walter Roberson
Walter Roberson 2012-2-9
The part before the ':' cannot contain a period.
  1 个评论
Kaustubha Govind
Kaustubha Govind 2012-2-9
Also, for more information: http://www.mathworks.com/help/releases/R2011b/techdoc/matlab_prog/bq9l448-1.html#bq9tdlq-1

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Error Handling 的更多信息

产品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by