c# - try catch bad form? -



c# - try catch bad form? -

i think sort of know reply this, there many ways things (some of wrong :) )...

i have little recursive function find employees manager's id. beingness used in import script , may persons immediate manager has left (been disabled) need find employees (the manager) manager (and on) can assign stuff them. in case isn't obvious, employeestodisable generic list of employees marked disabled in import.

i guess asking, : overhead associated catching exception much of trade off create in instance. , should doing differently. work fine, feels bad form..

i have code thus:

private guid getmyenabledmanagersid(onlineemployee e) { employee manager; seek { //see if employee e's manager in disabled list. manager = (from emp in employeestodisable emp.employeeid.equals(e.managerid) select emp).single(); //yes are, need phone call 1 time again homecoming getmyenabledmanagersid(manager); } grab { homecoming e.managerid; } }

leaving aside recursion, should perhaps utilize singleordefault , test null. actually, probably don't need total employee object - can suffice returning id (throughout), i.e.

private guid getmyenabledmanagersid(guid managerid) { var disabled = (from emp in employeestodisable emp.employeeid == managerid select (guid?)emp.managerid).singleordefault(); homecoming disabled == null ? managerid : getmyenabledmanagersid(disabled.value); }

actually, biggest concern have original form isn't specific type of exception; "thread abort", "zombie connection", "deadlock", etc.

c# asp.net exception-handling

Comments

Popular posts from this blog

java - How to set log4j.defaultInitOverride property to false in jboss server 6 -

c - GStreamer 1.0 1.4.5 RTSP Example Server sends 503 Service unavailable -

Using ajax with sonata admin list view pagination -