Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 10-12-2003, 02:46 PM   #1 (permalink)
npa
Code Monkey
 
Join Date: Jul 2003
Location: canada
Posts: 82
npa is on a distinguished road
c# exceptions

if, when using c# with asp.net, we have an exception that
we do not catch, i.e:

Code:
string s = null;
Response.Write(s.ToString());
we get the exact line numbers, etc, output when the
page displays the exception to us. we also get the
previous calls that have got us to this point (methods,
etc).

however, if we do something like:
Code:
// Page_Load(){
exceptionCheck();
// }

public void exceptionCheck(){
 try {
  throw new Exception("test");
 } catch(Exception e){
   Response.Write(e.ToString());
 }
}
we do not get the line-numbers from where this
method was called ... (exceptionCheck). why ? is it
just my setup ? i really need to have this ability
but i just can't figure it out .... i hope i am clear.
__________________
direct entry file specification.
npa is offline   Reply With Quote
Old 10-12-2003, 08:55 PM   #2 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,489
sde is on a distinguished road
i wish i could help .. i haven't worked much with asp.net .. but lots with c#.

it's nice to see someone else around here working with c# too =)

please post if you find an answer elsewhere.
__________________
Mike
sde is offline   Reply With Quote
Old 10-13-2003, 05:56 PM   #3 (permalink)
sdeming
Code Monkey
 
Join Date: Jul 2002
Location: Michigan
Posts: 85
sdeming is on a distinguished road
Use the StackTrace property:
Code:
public void exceptionCheck(){
 try {
  throw new Exception("test");
 } catch(Exception e){
   Response.Write(e.StackTrace);
 }
}
__________________
Scott
B4 09 BA 09 01 CD 21 CD 20 53 63 6F 74 74 24
sdeming is offline   Reply With Quote
Old 10-13-2003, 10:17 PM   #4 (permalink)
npa
Code Monkey
 
Join Date: Jul 2003
Location: canada
Posts: 82
npa is on a distinguished road
sdeming, the .toString contains that data already ...

the answer is actually to do:

Code:
catch(Exception e){
  System.Diagnostics.StackTrace st = new ... StackTrace();
  Response.Write(st.ToString());
}
you will, however, need to have "debugging" enabled
in your project. (or something like that).
__________________
direct entry file specification.
npa is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
VB or C#, or something else Apodysophilia MS Technologies ( ASP, VB, C#, .NET ) 6 10-15-2004 09:48 AM
operate overloading member function in C# sureshkumar_kc MS Technologies ( ASP, VB, C#, .NET ) 2 10-15-2004 02:36 AM
For those who have Learned C from "The C Programming Lanuage" DemosthenesB Standard C, C++ 5 07-13-2003 12:22 AM
edit? anon Lounge 10 11-21-2002 03:02 PM


All times are GMT -8. The time now is 10:01 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting