About ThrowNativeError
Is it fine to ThrowNativeError in a function which is called by a native?
Like here I want to create a client validation stock which will throw native errors so i can get rid of such lines in all of my natives Code:
if ( !IsClientIndex( iClient ) )Code:
return ThrowNativeError();I saw some natives do it, some not. Just a little confused |
Re: About ThrowNativeError
Although not marked as such, ThrowNativeError doesn't return, so sending back its returned value (which it will never return) is unnecessary.
I'm not exactly sure why it was given a return type and not void, but my best guess is simply that it was made to mimic its C++ equivalent, and also likely because native callbacks require you to return an int (and now any). Marking ThrowNativeError's return value as an int allows you to write PHP Code:
PHP Code:
Either way, just remember that this function doesn't "return" since it always throws an error. |
Re: About ThrowNativeError
C++ from SourceMod
https://github.com/alliedmodders/sou....cpp#L129-L149 *edit ThrowNativeError (and ThrowError) will throw error and abort code, you won't get return value. My guess. |
Re: About ThrowNativeError
I thought so. But anyway thanks for the answers.
But i'm still not sure about using ThrowNativeError inside non-native functions which are called by natives. Like this: Code:
stock void ThrowNativeErrorIfBadClient(int client, bool inGame = true) { |
Re: About ThrowNativeError
That works fine: https://github.com/SilvDev/Left4DHoo...hooks.sp#L5106
|
Re: About ThrowNativeError
Okay then, thanks.
|
| All times are GMT -4. The time now is 22:49. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.