Problem exists between keyboard and chair
I was writing code, in the zone, slinging features around and in general having a great time. I was able to create the structure that I wanted, and things worked. So I started to do another pass on the code, to make sure that we go the error handling right.
I ended up writing code similar to the following:
As you can see, spawning of dinos can fail. Maybe there aren’t enough resources, maybe I have reached the limits of this particular type of dino. Regardless of what exactly was failing, we would try a bunch of options before giving up. That way, we can be sure that the usual suspects has already been accounted for.
This code failed with a strange error: “Cannot change the horn VIN: ‘horn-18238a8as81’”.
I’m not setting the horn VIN anywhere, I’m using the high level API to spawn dinos, why am I seeing things in this manner. I debugged this, but I couldn’t figure out what was going on. I run the code on a separate project, and it worked. I rules out web app vs. console app, I decompiled the code and looked at things, I sniffed the network and looked into what was going on. I was completely lost.
At that point, I called another dev over to look at things and tried to explain what was going on. As I was going on and on about all the things that I tried and how much I hate the Jurassic period and how the Triassic has a much better API, he gently coughed and asked me if I’m not missing a break here.
I actually looked at the code and wanted to cry. My code did the exact thing that I asked it to. If I was able to successfully spawn a dino, I would go ahead and create another one, with the same name. It looks like deep in the guts of the system, there were assignments of ids to the various pieces, and trying to create an instance with the same name caused this error.
Cue head on keyboard a few times, a single statement added and everything worked.
I literally spent a few hours on this thing, which is really embarrassing. I would probably spend a lot more if I didn’t have a fresh set of eyes come and point it out.
Comments
What's
username
in the above snippet?Jurassic.Define($"{username}.Battle.Mount")
Know the feeling. Done that many times. The real question is when can we expect the Hibernating Rhino Dinosaur game?
The next time, perhaps you could use the Rubber Duck Debugging method
https://en.wikipedia.org/wiki/Rubber_duck_debugging
So the error is a missing
break
?Pop, Some username, that is all. Assume it can be
ayende
orpop-catalin
Pop, Yes
Hmmm... I could almost swear that code doesn't compile...
Jorge, You are correct. I should have set it to null there, fixed.
@Ayende, I think this is a clear sign a vacation is welcome 😉
PICNIC problems! (Problem In Chair Not In Computer)
Why did the code succeed when you ran it in a different project?
Derrick , In the other project, I was running this outside the loop, because I copied just the relevant parts.
Comment preview