Killing my web service

E

Eric

Hello,

I've written a c# web service that functions as a test harness. It
mimics the user interface of a client's web service. I would like to
make it die based on being passed in a certain parameter, so that I can
simulate a timeout. The actual time out is configurable in the
application that calls my test harness and my test harness isn't aware
of what this is set to.

I'm looking for:

public function myfunction (string param1, string param2)
{
if (this == that)
{
//something should go here to exit the web service without
returning anything.
throw new MyTimeOut();
}
catch ( MyTimeOut ex )
{
//Just fall into the finally block
}
finally
{
}
}

public class MyTimeOut : System.ApplicationException
{
}

I tried throwing a custom exception as shown above, but got the error
message that not all code paths returned a value.

-Eric
 
M

Miha Markic [MVP C#]

Eric said:
Hello,

I've written a c# web service that functions as a test harness. It
mimics the user interface of a client's web service. I would like to
make it die based on being passed in a certain parameter, so that I can
simulate a timeout. The actual time out is configurable in the
application that calls my test harness and my test harness isn't aware
of what this is set to.

I'm looking for:

public function myfunction (string param1, string param2)
{
if (this == that)
{
//something should go here to exit the web service without
returning anything.
throw new MyTimeOut();
}
catch ( MyTimeOut ex )
{
//Just fall into the finally block
}
finally
{
}
}

public class MyTimeOut : System.ApplicationException
{
}

I tried throwing a custom exception as shown above, but got the error
message that not all code paths returned a value.

Because they don't.
Place a return value (dummy value perhaps) in the last line and you'll be
fine.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top