Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

请问是否支持C#的try...catch? #27

Closed
roundsheep opened this issue Jan 5, 2017 · 4 comments
Closed

请问是否支持C#的try...catch? #27

roundsheep opened this issue Jan 5, 2017 · 4 comments

Comments

@roundsheep
Copy link

roundsheep commented Jan 5, 2017

例如这种代码如何翻译为lua代码?

void test1()
{
	throw new Exception("abc");
}
void test5()
{
	try
	{
		try
		{
			try
			{
				test1 ();
			}
			catch(Exception ex)
			{
				Debug.Log (ex.Message);
				throw new Exception("efg");
			}
		}
		catch(Exception ex)
		{
			Debug.Log (ex.Message);
			throw ex;
		}
	}
	catch(Exception ex)
	{
		Debug.Log (ex.Message);
	}
}
@chexiongsheng
Copy link
Collaborator

lua的对应语法应该是pcall,你可以查阅下相关资料哈。。

@roundsheep
Copy link
Author

话说如何在lua虚拟机和C#之间互相抛异常?如果C#抛出一个异常,xlua虚拟机能接收到么

@chexiongsheng
Copy link
Collaborator

可以的互相抛,互相catch的,xLua做了异常的转换。

@roundsheep
Copy link
Author

额,那我去学习研究下

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants