.NET Fiddle

CSharp · Console

/Program.cs

using System;
using System.Runtime.ExceptionServices;

public class Program
{
	public static void Main()
        {
            Console.WriteLine("Method1: ");
            try { MagicMethod_ExactlyErrorLine(0); }
            catch (Exception ex) {
                Console.WriteLine(ex);
            }
            Console.WriteLine();
            Console.WriteLine("Method2: ");
            try { MagicMethod_NoIdeaWhereIsAnError(0); }
            catch (Exception ex) {
                Console.WriteLine(ex);
            }
        }
        public static void MagicMethod_ExactlyErrorLine(int d)
        {
            try {
                int w = MagicMethodInner_ExactlyErrorLine(d);
            }
            catch (Exception ex) {
                // Do something with ex, logging for example
                throw; // rethrow
            }
        }
        public static void MagicMethod_NoIdeaWhereIsAnError(int d)
        {
            try {
                int w = MagicMethodInner_NoIdeaWhereIsAnError(d);
            }
            catch (Exception ex) {
                // Do something with ex, logging for example
                throw; // rethrow
            }
        }
        public static int MagicMethodInner_ExactlyErrorLine(int d)
        {
            return 1 / d;
        }
        public static int MagicMethodInner_NoIdeaWhereIsAnError(int d)
        {
            try { return 1 / d; }
            catch (Exception ex) {
                Console.WriteLine("{0}", ex.Message);
                throw;
            }
        }
}
;