Open CrosRoad95 opened 7 hours ago
Appendum: Make a way to catch warnings too
Warnings are just warnings, like you put "0" instead of 0, mta converted it but you should use numeric zero, not string, or like example i gave before: setting position of something what is not element should be error, but isn't, there is many such cases, we can not change it because even if your code is broken, we can not break your broken code.
Again, this warning above can cause server/client to fall into invalid state, let's say after you set position you print log to admin, but this log doesn't depend on this element - "platform was moved", now you get log, but imaginary platform didn't move. You can see in logs both but if you have tons of logs you may get lost
I mean, if a warning is thrown then most of the time the function returns false so you can check against that.
you can check against that.
Yes, you can, but making code in shape of pyramid of doom is not good
if (!setElementPosition(...)) then
error("Invalid args")
end
? In some cases, it is unavoidable. This is the way if you want to have errors when warning is thrown
if (!setElementPosition(...)) then error("Invalid args") end
? In some cases, it is unavoidable. This is the way if you want to have errors when warning is thrown
Yes, and you double your codebase, i probably prefer to just fork mta and replace all warnings with errors instead of dealing with that shit
Is your feature request related to a problem? Please describe.
Steal i mean, borrow concept of treating warnings as errors. https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/compiler-options/errors-warnings
Describe the solution you'd like
Assign id to every warning, add option to treat them as errors, for example:1 , next time code will stop execution and you will see error instead of continuing execution
setElementPosition(false, 0, 0, 0)
-WARNING: [1] server.lua:1: Bad argument @ 'setElementPosition' [Expected element at argument 1, got boolean]
where "[1]" is id of warning. But in practice this should be an error. so, you go to mtaserver.conf, find and add warning:This is 101% backwards compatible
Describe alternatives you've considered
/
Additional context
/
Security Policy