exception while signaling: Must be a LuaSourceContainer - exception

So I was just making game on Roblox and met strange exception:
exception while signaling: Must be a LuaSourceContainer - Studio
I think it comes from my own custom humanoid UI, but I am not sure.
Any suggestions how to fix it?

So, I found out what I am doing wrong. I used
Humanoid.HealthChanged.Connect:(function()
--Changing UI
end)
When I needed to do something like this:
Humanoid:GetAttributeChangedSignal("Health"):Connect(function()
--Function body
end)
But unfortunately, only Players have attribute Health. So, I used repeat loop until my humanoid health reaches (<=) 0. Very important to mention that if you use Humanoid.Died signal, you will instantly leave loop. I redid code and now it looks like this:
repeat
--Function body
wait(0.01) --NOTE: If you won't use wait(), you will freeze studio and get error.
until Humanoid.Health <= 0
Hopefully, this was helpful to anyone.

Related

Java supplier interface with org.powermock.reflect.exceptions.MethodNotFoundException

I have mock a https://github.com/elastic/elasticsearch/blob/master/core/src/main/java/org/elasticsearch/client/transport/TransportClient.java with Powermockito, before it works, but since the code chanage and add below code:
NetworkModule networkModule = new NetworkModule(settings, true, pluginsService.filterPlugins(NetworkPlugin.class), threadPool,
bigArrays, circuitBreakerService, namedWriteableRegistry, xContentRegistry, networkService);
final Transport transport = networkModule.getTransportSupplier().get();
the code alway fail at getTransportSupplier().get(), the throws exception:
Caused by: org.powermock.reflect.exceptions.MethodNotFoundException: No methods matching the name(s) get were found in the class hierarchy of class java.lang.Object.
at org.powermock.reflect.internal.WhiteboxImpl.getMethods(WhiteboxImpl.java:1720)
at org.powermock.reflect.internal.WhiteboxImpl.getMethods(WhiteboxImpl.java:1745)
at org.powermock.reflect.internal.WhiteboxImpl.getBestMethodCandidate(WhiteboxImpl.java:983)
at org.powermock.core.MockGateway$MockInvocation.findMethodToInvoke(MockGateway.java:317)
at org.powermock.core.MockGateway$MockInvocation.init(MockGateway.java:356)
at org.powermock.core.MockGateway$MockInvocation.<init>(MockGateway.java:307)
at org.powermock.core.MockGateway.doMethodCall(MockGateway.java:142)
at org.powermock.core.MockGateway.methodCall(MockGateway.java:125)
at org.elasticsearch.client.transport.TransportClient.buildTemplate(TransportClient.java:162)
networkModule.getTransportSupplier() returns Supplier.
here is code from networkModule: https://github.com/elastic/elasticsearch/blob/master/core/src/main/java/org/elasticsearch/common/network/NetworkModule.java
any idea why?
I think this is a bug with Powermock.
See that entry in their issues database; which shows the same stack trace (although for some different target). But close enough.
So, chances are, this will be fixed at some point. Or not.
Long story, short rant: I have seen too many such problems with PowerMock; thus I decided at some point that I rather fix my broken designs; instead of using the PowerMock hammer. In my experience, when we talk about "our own code"; then we simply create easy-to-test code; and then we do not need PowerMock any more. Seriously, that works. When you create your own classes, and you need PowerMock to test that; then you did something wrong! And as soon as you stop using PowerMock; you stop spending time on problems that have nothing to do with your product.
Anyway, your option space is:
Subscribe to that defect; and try to get some attention to it; the more people go there and give "me too", the more likely something will happen.
Look into your design and have a closer look why you need PowerMock(ito). And then decide if you would benefit from eliminating this requirement by changing your production code.

Amending a condition as the stack unwinds in Common Lisp

I'm working on some lisp code that munges a CVS repository in order to get it into shape for a git conversion. As such, when something goes wrong it might not be a bug in my code but might instead be an inaccuracy in the input data which needs fixing.
Deep down in the bowels of my code, I'll have (say) some function that merges two date ranges by taking an intersection. If that intersection turns out to be empty, I'll raise an error. This is all good, but my "merge dates" function is missing lots of the information that the user (me!) needs in order to figure out what went wrong. For example, which CVS master file ("foo,v") was I working on? What branch was I thinking about? Etc. etc.
My partial solution to this problem is to handle and re-raise the error. For example, this sort of code:
(handler-case
(do-something)
(unclear-graft-point (c)
(setf (slot-value c 'master) master)
(setf (slot-value c 'branch) branch)
(error c)))
which sets some extra slots with useful info before re-raising the error.
The report function for the condition then checks whether those slots have been set and, if so, will use them to give a more helpful error message.
Unfortunately, the backtrace that I get stops at the top-level re-raise. That makes sense: it's the code I wrote. But it's not really what I want...
Is there a way in Common Lisp to "annotate" a condition as it hurtles past, without re-raising it and, hence, partially unwinding the stack without reporting that in the back trace?
I gave a reasonable amount of background info about what I'm doing in the hope that, if this isn't possible, someone will say "Ah, what you should do in this situation is...": am I just going about this the wrong way?
Yes, there is a Common Lisp technology applicapble to your case - it is called HANDLER-BIND. You can find a detailed explanation and use cases for it alongside other condition-handling machinery in Peter Seibel's Practical Common Lisp Chapter 19. Conditions and Restarts.

Invalid method when method is valid

I have just started a new version of my Crysis Wars Server Side Modification called InfinityX. For better management, I have put the functions inside tables as it looks neater and I can group functions together (like Core.PlayerHandle:GetIp(player)), but I have ran into a problem.
The problem is that the specified method to get the players' name, player:GetName() is being seen as an invalid method, when the method actually is completely valid.
I would like to know if using the below structure is causing a problem and if so, how to fix it. This is the first time I've used this structure for functions, but it is already proving easier than the old method I was using.
The Code:
Event =
{
PlayerConnect = function(player)
Msg.All:CenteredConsole("$4Event$8 (Connect)$9: $3"..player:GetName().." on channel "..player.actor:GetChannel());
System.LogAlways(Default.Tag.."Incoming Connect on Channel "..player.actor:GetChannel());
Event:Log("Connect", player);
end;
};
The below code works when I bypass the function and put the code directly where it's needed:
Msg.All:CenteredConsole("$4Event$8 (Connect)$9: $3"..player:GetName().." on channel "..player.actor:GetChannel());
System.LogAlways(Default.Tag.."Incoming Connect on Channel "..player.actor:GetChannel());
The Error:
[Warning] [Lua Error] infinityx/main/core.events.lua:23: attempt to call method 'GetName' (a nil value)
PlayerConnect, (infinityx/main/core.events.lua: 23)
ConnectScript, (infinityx/main/core.main.lua: 52)
OnClientEnteredGame, (scripts/gamerules/instantaction.lua: 511)
(null) (scripts/gamerules/teaminstantaction.lua: 520)
Any clarification would be appreciated.
Thanks :)
Well, as PlayerConnect is inside the table Event, and you are calling with a ":", add self as first arg in the function, like:
PlayerConnect = function(self, player)
Clearly, player in the first block of code is not the same as player in the second block of code. The problem must be that the caller of Event.PlayerConnect is not passing the same value.
To test that your Event.PlayerConnect function works, try this in the same place as your second block of code:
Event.PlayerConnect(player)
That should work as you expect.
So, the problem comes down to how Event.PlayerConnect is called without the second block of code. I'm not familiar with that game engine so I don't know how it is done. Perhaps reviewing the documentation and/or debugging that area would help. If you print(player) or call the equivalent log function in both cases, you should see they are different. If you can't run in a debugger, you can still get a stack trace with print(debug.traceback("Accessing player, who's value is: "..player)). If there is indeed some kind of table-based player object in both cases, you can try comparing their fields to see how they are different. You might need to write a simple dumping function to help with that.

Bada exceptions on RemoveAllControls call

What's the deal with this, it's driving me crazy?
I run this piece of code;
if(GetControlCount() > 0)
{
RemoveAllControls();
}
And as soon as I step over the RemoveAllControls(); line I get the following exceptions;
12557.709,EXCEPTION,P44,T00,A174,Osp::Ui::Container::GetControlAt (392) > [E_OBJ_NOT_FOUND] Unable to find the specified control.
12557.709,EXCEPTION,P44,T00,A174,Osp::Ui::Container::RemoveControl (247) > [E_OBJ_NOT_FOUND] Propagated.
If the problem is that there are no controls, surely my check should be solving this? So what's the deal?
I have also tried naming the controls individually, null checking them an then removing them if they are not null, but again, I get these exceptions.
12557.709,EXCEPTION,P44,T00,A174,Osp::Ui::Container::GetControlAt (392) > [E_OBJ_NOT_FOUND] Unable to find the specified control.
12557.709,EXCEPTION,P44,T00,A174,Osp::Ui::Container::RemoveControl (247) > [E_OBJ_NOT_FOUND] Propagated.
Is it possible that these are being flagged from a different place in your code? You should try and catch the result to make doubly sure it is coming from where you think. There are several variations of Control::Remove and the AppLog doesn't exactly match the ones you call so perhaps you call other, similarly named ones elsewhere and you are seeing their internal implementation(s) throwing exceptions.

Code that detects its own bugs?

Consider the following code snippet:
int index = FindClosestIndex(frame);
if (_data[index].Frame == frame)
return _data[index];
else
return interpolateData(frame, _data[index - 1], _data[index]);
Now, in this case I have done some checking before this code block to make sure that FindClosestIndex() will never return 0. It should be impossible. However, the logic in FindClosestIndex is somewhat complex, so it's very possible that a bug has yet to be discovered in some rare corner case that no one anticipated, and even though my code is correct, FindClosestIndex may incorrectly return 0.
If it does return 0, I will get an ArgumentOutOfRangeException on the _data[index - 1] statement. I could let that exception bubble up, but I would rather do this:
if (index == 0)
throw new ApplicationLogicException("There is a bug that caused FindClosestIndex to return an int <= 0 when it shouldn't have.");
Would you recommend this practice of throwing a custom exception if your code detects an error state? What do you do when you have a situation like this?
Personally, I do include custom exceptions like that. It's like the condom argument: it's better to have it and not need it than to need it and not have it. If in the rare case that it does occur, including the custom exception message will make tracking down the logic error that much easier, yet your executable is only a tiny bit bigger. Otherwise, your ArgumentOutOfRangeException could happen anywhere. The time it takes you to add the exception far outweighs the time it takes you to track down the error without it.