KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
Is it possible to change this code, with a return value and an exception: public Foo Bar(Bar b) { if(b.Success) { return b; } else { throw n.Exception; } } to this, which throws separate exceptions for success and failure public Foo Bar(Bar b) { throw b.Success ? new BarException(b) : new FooException(); } try { Bar(b) } catch(BarException bex) { return ex.Bar; } catch(FooException fex) { Console.WriteLine(fex.Message); }
Tags (comma-separated)
Save Edits
Cancel