xreturn for php

前回 作った C++ での xreturn というエラーハンドリングの phpバージョン。
自分的には、こっちのほうが先なんだけど、、、

<?php

class xreturn
{
	var $message ;
	var $code ;

	function __construct($message,$code)
	{
		$this->message = $message;
		$this->code = $code;
	}
	
	function getMessaage()
	{
		return $this->message;
	}
	function getCode()
	{
		return $this->code;
	}

	static function iserror($obj)
	{
		return
		 is_object($obj) && strtolower(get_class($obj)) == "xreturn";
	}
	static function check($obj)
	{
		if ( iserror($obj) )
		{
			throw new Exception($obj->getMessage() , $obj->getCode() );
		}
		return $obj;
	}
}

//以下検証コード

function mul($a,$b)
{
	if ($b == 0) return new xreturn("0禁止になっております",0);
	return $a * $b;
}

$r = mul(1,0);
if ( xreturn::iserror($r) )
{
	//エラー
	echo "error";
	die;
}
echo "ok";