Skip to content

Instantly share code, notes, and snippets.

@timabell
Last active July 24, 2019 16:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save timabell/78610f588961bd0a0b95 to your computer and use it in GitHub Desktop.
Save timabell/78610f588961bd0a0b95 to your computer and use it in GitHub Desktop.
using System;
class puke{
static void Main(string[] args) {
try {
ThrowException1();
} catch (Exception x) {
Console.WriteLine("Exception 1:");
Console.WriteLine(x);
}
try {
ThrowException2();
} catch (Exception x) {
Console.WriteLine("Exception 2:");
Console.WriteLine(x);
}
try {
ThrowException3(); // line 18
} catch (Exception x) {
Console.WriteLine("Exception 3:");
Console.WriteLine(x);
}
}
private static void ThrowException1() {
try {
DivByZero(); // line 27
} catch {
throw;
}
}
private static void ThrowException2() {
try {
DivByZero(); // line 35
} catch (Exception ex) {
throw ex;
}
}
private static void ThrowException3() {
try {
DivByZero(); // line 43
} catch (Exception ex) {
throw new Exception("doh", ex); // line 45
}
}
private static void DivByZero() {
int x = 0;
int y = 1 / x; // line 51
}
}
-----
Loaded assembly: /home/tim/repo/puker/bin/Debug/puke.exe
Exception 1:
System.DivideByZeroException: Division by zero
at puke.DivByZero () [0x00002] in /home/tim/repo/puker/puke.cs:51
at puke.ThrowException1 () [0x00000] in /home/tim/repo/puker/puke.cs:27
Exception 2:
System.DivideByZeroException: Division by zero
at puke.DivByZero () [0x00002] in /home/tim/repo/puker/puke.cs:51
at puke.ThrowException2 () [0x00000] in /home/tim/repo/puker/puke.cs:35
Exception 3:
System.Exception: doh ---> System.DivideByZeroException: Division by zero
at puke.DivByZero () [0x00002] in /home/tim/repo/puker/puke.cs:51
at puke.ThrowException3 () [0x00000] in /home/tim/repo/puker/puke.cs:43
--- End of inner exception stack trace ---
at puke.ThrowException3 () [0x0000b] in /home/tim/repo/puker/puke.cs:45
at puke.Main (System.String[] args) [0x00040] in /home/tim/repo/puker/puke.cs:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment