c# - How to throw exceptions when called from library? -
i defining convention automapping in fluent nhibernate. within convention, throw exception:
public void apply(imanytomanycollectioninstance instance){ ... if(<error>) throw new mappingexception("invalid mapping"); <dosomestuff> } in class, initialize configuration, resulting in code above beingness executed:
public void init(){ try{ sessionfactory = configuration.buildsessionfactory(); // apply(...) called here } grab (mappingexception ex) { <catcherror> } when <error> true, <dosomestuff> highlighted visualstudio , warned "mappingexception unhandled user code".
why exception not thrown until <catcherror>?
the fluent nhibernate library added nuget bundle manager. if reason exception not forwarded, how can send mappingexception <catcherror>?
the reason behavior have checked next option: debug -> exceptions -> column "thrown" "common language runtime exceptions".
if nail f5 or otherwise go on debugging, code reach <catcherror>.
c# exception-handling
No comments:
Post a Comment