Why not just change it to
int foo(int x, y)
{
if (y == 0)
throwException("Doh!");
return x/y;
}
This gives the same runtime results, and the compiler won’t complain.
More Related Contents:
- How to make [DebuggerNonUserCode] hide an exception from the debugger in simple test case?
- Input string was not in a correct format
- Custom Compiler Warnings
- Collection was modified; enumeration operation may not execute in ArrayList [duplicate]
- Handling unhandled exceptions problem
- .NET – What’s the best way to implement a “catch all exceptions handler”
- Troubleshooting BadImageFormatException
- A Task’s exception(s) were not observed either by Waiting on the Task or accessing its Exception property. As a result, the unobserved exception was
- How do I get the member to which my custom attribute was applied?
- Turn on IncludeExceptionDetailInFaults (either from ServiceBehaviorAttribute or from the configuration behavior) on the server
- Should I use AppDomain.CurrentDomain.BaseDirectory or System.Environment.CurrentDirectory?
- How to set dynamic value in my Attribute
- Active Directory COM Exception – An operations error occurred (0x80072020)
- Exceptions that can’t be caught by try-catch block in application code
- What’s the difference between using the Serializable attribute & implementing ISerializable?
- Attributes in C#
- Image.FromStream() method returns Invalid Argument exception
- Best practices: throwing exceptions from properties
- Attribute on Interface members does not work
- Are P/Invoke [In, Out] attributes optional for marshaling arrays?
- Catching exceptions with “catch, when”
- How to pass objects into an attribute constructor
- Is there a built in .NET exception that indicates an illegal object state?
- Can C# Attributes access the Target Class?
- In a .net Exception how to get a stacktrace with argument values
- Which exceptions shouldn’t I catch?
- The given key was not present in the dictionary. Which key?
- How to wrap a method via attributes?
- Can you use “where” to require an attribute in c#?
- How to get the name of the method that caused the exception