# Try-Catch

姑妄行此
	嗚呼「「滅頂」」之禍

如事不諧「「ReferenceError」」之禍歟
	吾有「「本無此物。奈何用之」」書之

「「SyntaxError」」之禍歟
	吾有「「不合文法。不通之甚」」書之

「「TypeError」」之禍歟
	吾有「「物各其類。豈可混同」」書之

「「滅頂」」之禍歟
	吾有「「嗚呼哀哉。伏维尚飨」」書之

不知何禍歟名之曰「奇禍」
	吾有「「人坐家中。禍從天降」」書之

乃作罷

Which is roughly equivalent to this JavaScript:

try {
	var e = new Error(); e.name = "滅頂"; throw e;
} catch(e) {
	if (e.name == "ReferenceError")
		console.log("本無此物。奈何用之")
	else if (e.name == "SyntaxError")
		console.log("不合文法。不通之甚")
	else if (e.name == "TypeError")
		console.log("物各其類。豈可混同")
	else if (e.name == "滅頂")
		console.log("嗚呼哀哉。伏维尚飨")
	else
		console.log("人坐家中。禍從天降")
}

If you do not need to catch the errors, you can do:

姑妄行此
	嗚呼「「無足輕重」」之禍
如事不諧乃作罷

Which roughly equals to:

try {
	var e = new Error(); 
	e.name = "無足輕重"; 
	throw e;
} catch(_) {

}

You can also do this to catch any error:

姑妄行此
	嗚呼「「事不關心」」之禍
如事不諧不知何禍歟書之乃作罷

Which roughly equals to:

try {
	var e = new Error(); 
	e.name = "事不關心"; 
	throw e;
} catch(e) {
	console.log(e);
}

You can see details about the usage in ./examples/try.wy.