🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Tangent: Exceptions

Published June 05, 2009
Advertisement
Spent some time last night implementing exceptions. Nothing too special here. try/throw/catch/finally as they exist in C#. Under the hood, I just use the existing exception mechanism to do the delivery, and wrap exceptions so that the runtime can distinguish between exceptions raised in the runtime and exceptions raised by the runtime.

The two main differences are that you may throw any object, not just exceptions and that the catch parameters use Tangent types. So the catch uses structural subtyping to see if an exception matches it. Not big changes, just little things to keep the feel of the language consistent.

The example test code of the day:

public static	main()=>void{	try{		//throw "moo.";		//throw 42;		throw 3.14;	}catch(string speech){		Console.WriteLine(speech);	}catch(int count){		Console.WriteLine(count);	}finally{		Console.WriteLine("finally.");	}}
Next Entry Tangent: Using
0 likes 0 comments

Comments

Nobody has left a comment. You can be the first!
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Profile
Author
Advertisement
Advertisement