Anyone understood what InnerExceptions are?

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Hi all,

Why am I getting a null value to the InnerException object?

namespace InnerException
{
class D
{
public static int Divide(int i, int j)
{
if (j == 0)
throw new DivideByZeroException("Division by zero is
forbidden.");

return i / j;
}
}

class Program
{
static void Main(string[] args)
{
try
{

int i = int.Parse (Console.ReadLine());
int j = int.Parse(Console.ReadLine()); // enter a 0
value

Console.WriteLine(D.Divide (i , j));
}
catch (Exception ex)
{
if (ex.InnerException != null)
Console.WriteLine("Inner Exception: " +
ex.InnerException.ToString());
else
Console.WriteLine(ex.Message);
}
}
}
}

sample I/O
========
2
0
Division by zero is forbidden.

Can anyone elaborate using examples?

Thanks in advance,
Muler

.



Relevant Pages

  • Re: Anyone understood what InnerExceptions are?
    ... Why am I getting a null value to the InnerException object? ... public static int Divide ... Division by zero is forbidden. ...
    (microsoft.public.dotnet.languages.csharp)
  • [PATCH] 2/2 Prezeroing large blocks of pages during allocation Version 4
    ... Have USERZERO and KERNZERO for different types of zero pages to avoid ... This is a patch that makes a step towards merging the modified allocator ... static inline void inc_reserve_count(struct zone *zone, ... +static inline void prep_zero_page(struct page *page, int order, int gfp_flags) ...
    (Linux-Kernel)
  • Re: edit and continue
    ... > Are you using the same sourcesafe I'm using. ... > safe crashing vb6. ... Zero random rollbacks (I can see why this would be a bad ... > int", the professional works on code daily and would much rather type "int ...
    (microsoft.public.vb.general.discussion)
  • Re: Matrix multiplication 3*3
    ... differ in how they handle int 10h/0Eh. ... it does color 7 to video "page" zero. ... Your PRINT_NUMBER routine should... ... nines:) You don't check for overflow, ...
    (comp.lang.asm.x86)
  • Re: [PATCH] Avoid buffer overflows in get_user_pages()
    ... In particular, "len" is a signed int, and it is only checked at the ... So, if it is passed in as zero, the loop ... I think that, if get_user_pageshas been asked to grab zero pages, ... Which is a bug, and you want to catch it. ...
    (Linux-Kernel)