Debug.Assert, try/catch/finally block strategy question

I'm sick of putting break points in try catch blocks and finding errors that way when I'm debugging

I love Debug.Assert -
Instead of putting break points in every catch block, I wish there was a way to do something like assert...
Get ready to blast your energy levels into high gear with Sedgewick Energy Drink. High powered adaptogenic herbs mixed with potent levels of B-vitamins and...

Please disregard the contents of this post.
0
sedgewick
1/1/2004 1:12:48 AM
asp.net.free-for-all 9281 articles. 0 followers. Follow

4 Replies
648 Views

Similar Articles

[PageSpeed] 7

what in the world are you doing debugging like that?  Use the command window, and other tools also.

There is no better means of doing anything than to step into/through your code. also, in your catch, you should be handling the exception. Unless you're one of those programmers that use
try {
}
catch {
//nothing
}
finally{
//nothing
}
.... if so. there is no help for you
Kay Lee
MySpace.com - http://www.myspace.com/kragie
Infrastructure Group
MySpace.com

- Code to live, but Live to code.
0
KraGiE
1/1/2004 1:16:01 AM
I got a million functions, a few are fatal, but most are recoverable.  Putting breakpoints in the catch block seemsto be the fastest way to track them down right now

I Really wish there was some code that would act like a break point to you can inspect.

internal static void SubscribeToRssChannel(string url)
{
SqlConnection cn = new SqlConnection(Nata1.Globals.ConnectionString);
try
{
throw new Exception("testing debug.assert");
// sql stuff here }
catch(Exception ex)
{
Debug.Assert(false,"Error subscribing to rss feed at " + url);
LogUtility.LogError(EntryType.RecoverableError,DateTime.Now,"Error subscribing to rss feed at " + url,ex);
}
finally
{
if(cn.State != ConnectionState.Closed)cn.Close();
}
}

.... but that Is a crappy way to debug. Better to just put the break point on the LogUtility line, and get rid of the Debug.Assert crap because its pointless.
Hell I set it to false how cool is that.

try {
}
catch {
//nothing
}
finally{
//nothing
}

I actually FOUND that in a code block. FxCop should have flagged that, its the Lamest way of doing things.
Get ready to blast your energy levels into high gear with Sedgewick Energy Drink. High powered adaptogenic herbs mixed with potent levels of B-vitamins and...

Please disregard the contents of this post.
0
sedgewick
1/1/2004 3:22:16 AM
OK wait - let me try this

I wish there was a way, or wanna know if there's a way to programmatically break execution

I'm sometimes throwing an exception 10 calls deep in the stack, and I can look at the log but thats lame
Totally lazy. Dunno though, seems like the place you wanna break into code the most is in a catch block so you can expect the exception block.
I'm an f*in whinner
Get ready to blast your energy levels into high gear with Sedgewick Energy Drink. High powered adaptogenic herbs mixed with potent levels of B-vitamins and...

Please disregard the contents of this post.
0
sedgewick
1/1/2004 3:53:49 AM
If you put the break point in the catch block, it won't stop execution unless there was an exception.  You can also pull back the execution up to the method the break is at if you need to if you want to re-step through the process.
Kay Lee
MySpace.com - http://www.myspace.com/kragie
Infrastructure Group
MySpace.com

- Code to live, but Live to code.
0
KraGiE
1/1/2004 5:12:50 AM
Reply:

Similar Artilces:

Try Catch Question about Finally
Hi folks, Inside of a function that returns an integer I do a databse call. Se code below. If I do the following and there is an exception does the finally get performed? If there is an exception and the "ParamReturn.Value" is 1 what gets returned. I'm just a little confused on the sequence of events. <CODE>Try   objConn.Open()  objCmd.ExecuteNonQuery() Catch ex As Exception   Return 2 Finally  objConn.Close() End Try Return ParamReturn.Value </CODE>John BelthoffDodge, Duck, Dip, Dive & DodgeIf a man can dodge a wrench, he can dodge a...

Try/Catch/Finally Question
I am trying the Try/Catch/Finally and I am getting the "myconn" is not declared. I didn't get this error until I put in the Try/Catch/Finally, any reason why? Try Dim webnew As Boolean = TrueDim WebID As IntegerDim contactID As IntegerDim reportID As IntegerDim strConn As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _"c:\accmon\database\accmon.mdb" & ";" '********************************************'Load Website tableDim MySQL As String = "Insert into websites (agencyID, url, service, addressIP, webnew)" & _  "Values (@DOTAgency, @URL, @ServiceType, @IPAddre...

Nested Try/Catch/Finally blocks
Hey guys. I'm doing some basic I/O stuff, and I've stumbled across a problem - I had some presumptions about how Try/Catch/Finally blocks are supposed to be used. Can't find anything easily, so I figure I'd come here and someone else could sort me out. Here's some pseudocode. 1 try 2 { 3 // Open I/O source stream 4 try 5 { 6 // Open I/O destination stream 7 try 8 { 9 // Buffer data from source to destination 10 } 11 catch (Exception ex) 12 { 13 ...

using try-catch-finally block
  Hi, Any one knows how much better is to use try-catch-finally block. Advantages and Disadvantages of using try-catch-finally block. Any gud web link...?SSNPlease remember to click "Mark as Answer" on the post that helps you. see this below link you can get more things. http://www.webreference.com/js/column118/3.htmlThiruHope this help someone in the future MSDNWe All move to our original place.Don't forget.Imran Baloch hi, these articles may help http://www.csharphelp.com/archives/archive167.html http://www.c-sharpcorner.com/UploadFile/rajeshvs/ExceptionHan...

try-catch block inside a loop question
foreach (Item item in MyItems){   //many processing statements preceding the try-catch      try{      expression that would throw an exception      //this iteration is shot, so do I need to explicitly say continue to go on to the next iteration?      continue;   }   catch{         HttpContext.Current.Trace.Warn("MyComponent",       ...

Connection.StateChange event with Try...Catch...Finally block
Hi my friends, I have a big problem when I'm trying to handle the Connection.StateChange event.I've added an handle to this event and at my try...catch...finally block I did this: Try{open connection}{begin transaction}{commit transaction}Catch{roolback transaction}Finally{close connection} The problem is: when the finally block calls Close command, the handle to the StateChenge event isn't called. But, if I call Close command from other part of the method, the event is called. What's happen?  Regards, JP....

How to tun off exception messages from Try Catch Block when debugging?
Hi, is it possible to turn off exception errors caused within a Try - Catch block when debugging? I use generalized code that call window controls withn a try -catch block, like: for i=1 to cnt try control[i].function dynamic of_load(BusinessObject) catch ... next When I need to debugg code that is executed after the loop above, the debugger stops at all failed dynamic calls withing the try - catch block. This is frustrating as debbuging becomes almost impossible, due to all dynamic call errors. So, is it possible to turn off the exception errors somehow? Th...

DataReader in a Try Catch Finally Block Closing Prematurely
Hi all. I have an object that is used to access my database. One of the methods in this object returns a DataReader so I can fill a repeater control on a page that displays tabular information. My problem is that the DataReader is being closed before it gets bound to the repeater control. This gives me an error which says there is no data in the DataReader. Here is the pseudo-code: open sql connection try { create new sqlCommand set sqlreader = sqlCommand.executeReader return sqlReader } catch { close slConnection close sqlReader } finally { close sqlConne...

TRY...CATCH...FINALLY...END TRY
When Error accured. Process will run to the CATCH clause then run Finally Clause. But When Error not accured, Process will run to Finally Clause. So, Error accured or not, Finally Clause certain will to be run it. I don't know, if this, script in Finally Clause or after Finally's script, what's different? Thanks Leo I don't understand the question... but Finally is executed if the exception is thrown or not. "LEO" <leo@mail.nak.com.tw> wrote in message news:FZ6i83HKCHA.1020@forums.sybase.com... > When Error accured. Process will ru...

Try Catch Finally (Finally omit)
Hi, I am using VS.NET 2005. In previous version of VS.NET, we have Try, Catch & Finally, but why in VS.NET 2005 the Finally omit in VB.NET and it is still using in C#. I am asking in VB.NET as if we type Try and enter then only Try & Catch came but bydefault Finally not came and we required to manually enter it but but in C# when we type Try, the Catch & Finally byself come. Thanks in Advance. Einstein_Lover: Hi, I am using VS.NET 2005. In previous version of VS.NET, we have Try, Catch & Finally, but why in VS.NET 2005 the Finally omit in VB.NET and it is still using...

try catch finally / response.redirect / response.end flow control question
Hi Guys, Can any one tell me if the finally block would be executed in the following example (assuming that dbReader.read() returned false because no records were found).   Many Thanks! DanielTry dbCon = New SqlConnection(myconnectionstring) dbCon.Open() dbCom = dbCon.CreateCommand() strSQL + "SELECT * FROM bookings WHERE ID &gt; 9000" dbCom.CommandText = strSQL dbReader = dbCom.ExecuteReader() If dbReader.Read() Then 'init fields Else Response.Redirect("main.aspx") End if Finally dbReader.clo...

What if Finally throws an error in try-catch-finally?
can anyone tell me What if Finally throws an error in try-catch-finally? CheersBinowww.codepal.co.inPlease Mark as Answer if you find the post useful. It'll throw an exception - being in the finally block doesn't exclude your code from throwing exceptions.You can put another try/catch block inside the finally block if you want to trap exceptions there.  Then the exception that is generated in the Finally block will propagate up the call stack until a Catch block is found For example Sub Main()  Try    Foo()  Catch    Console.Wri...

Catch, Try Question and Stored Procedure Question
 Hi, i know that catch ex as SQLexception is for catching SQL error right? Then what is "catch ex as exception" for?  and also what is "Finally" used for? Another thing about stored procedure, what is the range of values that i can use for setting my own return values? like if exist (select * from table) return -101 <--- what is the range of numbers i can use these?and what are the other numbers like the positive numbers for? thanks To Under Stand the Try Catch and FInally you must read the following articles http://msdn.microsoft.com/en-us...

TRY...CATCH...FINALLY...END TRY statement
I am getting serious issues with the PB Statement TRY...CATCH...FINALLY...END TRY I am using: TRY ds_buffers[1].settransobject(SQLCA) Rows_Page=ds_buffers[1].retrieve(mdl_sk_itemref) ValColPage=ds_buffers[1].Object.sk_page[1,Rows_Page] CATCH (type of erro) messagebox("","") {FINALLY } END TRY I am getting Sintax Error. Anybody could help me out? this is my use of Try-catch TRY [...] CATCH (ctscomponents_createexception e) [...] FINALLY [...] END TRY It's your CATCH clause. Here's an excerpt from the help file...

Web resources about - Debug.Assert, try/catch/finally block strategy question - asp.net.free-for-all

Strategy - Wikipedia, the free encyclopedia
) is a high level plan to achieve one or more goals under conditions of uncertainty. Strategy is important because the resources available to ...

Strategy - Wikipedia, the free encyclopedia
while Max McKeown (2011) argues that "strategy is about shaping the future" and is the human attempt to get to "desirable ends with available ...

Branding Strategy Insider
Helping marketing oriented leaders and professionals build strong brands.

Strategy Informer: Every game has strategy
Strategy Informer HOME NEWS ARTICLES DOWNLOADS Media cheats/GUIDES COMMUNITY About us UPLOAD mods Buy games HOME top games upcoming games ALL ...

The Strategy Web™ - Tools, Tactics, Trends * Martin Meyer-Gossner is a web business strategist, trainer ...
Tools, Tactics, Trends * Martin Meyer-Gossner is a web business strategist, trainer & speaker

Virtual-Strategy Magazine - Your leading source for virtualization news
Virtual Strategy Magazine is an online publication devoted entirely to virtualization technologies.

What The Fuck is My Wearable Strategy?
Don’t forget to hit reload, there are some real gems in there.

China's nuclear policy, strategy consistent: spokesperson
China's nuclear policy, strategy consistent: spokesperson

Allstate's Mayhem Demonstrates Do-It-Yourself Fails - CMO Strategy - Advertising Age
Watch out, homeowners – Allstate 's Mayhem is back, and this time he's taking it upon himself to make some home improvements using online do-it-yourself ...

New Year’s Resolution for Publishers: Rethink Your Social Content Strategy
... and yet represent areas of opportunity for growth. This year, I challenge you to make some resolutions in regards to your social media strategy ...

Resources last updated: 1/3/2016 11:39:35 PM