S
Steve B.
Hi,
I'm wondering how to correctly throw exception within ASP.Net pages.
I've page wich which waits for an "id" parameter in the querystring. I want
to validate this param.
I've wrote this code :
if (Page.Request.QueryString["id"] == null)
{
throw new ArgumentNullException("id");
}
int id;
object o;
if (!int.TryParse(Request.QueryString["id], out id) || (o =
GetObjectFromDataBase(id)) == null)
{
throw new ArgumentOutOfRangeException("Inexistant or invalid ID", "id");
}
else
{
DoSomethingWithO(o);
}
Is it the correct exceptions to throw when validating query string
arguments?
Thanks in advance,
Steve
I'm wondering how to correctly throw exception within ASP.Net pages.
I've page wich which waits for an "id" parameter in the querystring. I want
to validate this param.
I've wrote this code :
if (Page.Request.QueryString["id"] == null)
{
throw new ArgumentNullException("id");
}
int id;
object o;
if (!int.TryParse(Request.QueryString["id], out id) || (o =
GetObjectFromDataBase(id)) == null)
{
throw new ArgumentOutOfRangeException("Inexistant or invalid ID", "id");
}
else
{
DoSomethingWithO(o);
}
Is it the correct exceptions to throw when validating query string
arguments?
Thanks in advance,
Steve