Closed LivingInPortal closed 10 years ago
If a ThrowNativeError be used in a normal function, a error "Not called from inside a native function" will be thrown, even if this is called from native function. Reference at: https://github.com/alliedmodders/sourcemod/blob/master/core/logic/smn_fakenatives.cpp#L138
This is intentional. I've delegated validation down the layers and this error will propagate up to to the native function handler.
Think like exceptions bubbling up in an object oriented language.
Better ideas are welcome. I want to avoid complex validation in the native function handers to keep them simple and clean. I also want to throw errors from as close as possible to the relevant code. I wish SourceMod had a universal version of ThrowError so it could be used in both places, or at least so that I could decide whether it should fail internally or in the calling plugin.
Thanks for the review anyways.
Well, I might have to do some experiments to clear my misconceptions. I always be interested on Zombie Reloaded project, my favorite game mode, which is a reason for I started programming. I hope i can help something. Thanks! On Oct 26, 2014 4:22 PM, "Richard Helgeby" notifications@github.com wrote:
This is intentional. I've delegated validation down the layers and this error will propagate up to to the native function handler.
Think like exceptions bubbling up in an object oriented language.
Better ideas are welcome. I want to avoid complex validation in the native function handers to keep them simple and clean. I also want to throw errors from as close as possible to the relevant code. I wish SourceMod had a universal version of ThrowError so it could be used in both places, or at least so that I could decide whether it should fail internally or in the calling plugin.
— Reply to this email directly or view it on GitHub https://github.com/rhelgeby/sm-zombiereloaded/pull/1#issuecomment-60522612 .
I made a thread about this issue. Maybe there's a better solution.
Yeah, this is really work out in a native. Sourcemod should call ThrowError rather than just call a warning when it doesn't come from a native.
Looks like it really is redundant, so removal of "PushArrayCell(ModuleList, module);" is correct, though this should be a separate commit.
Pushed another commit
ThrowNativeError should use in the native call, not in normal functions. Additionally, a duplicated operations in AddModuleToIndex RemoveModuleFromIndex functions removed.