node-minecraft-protocol icon indicating copy to clipboard operation
node-minecraft-protocol copied to clipboard

print the value for out of bound error

Open rom1504 opened this issue 10 years ago • 3 comments

Client: TypeError: Write error for play.toClient.entity_head_rotation.headYaw : value is out of bounds is nice, but it would be nicer with the value.

rom1504 avatar Oct 12 '15 21:10 rom1504

I believe this is mostly about adding a try catch in https://github.com/roblabla/ProtoDef/blob/master/src/datatypes/numeric.js

rom1504 avatar Nov 20 '15 11:11 rom1504

try/catch are not optimizable in v8 so I'm not sure if that should be done at all.

rom1504 avatar Mar 21 '16 09:03 rom1504

you can optimize try/catch by making a special tryCatch function like so :

function tryCatch(tryfn, catchfn, finalizefn) {
  try {
    tryfn();
  } catch (e) {
    if (typeof catchfn === "function") catchfn(e);
  } finally {
    if (typeof finallyfn === "function") finallyfn();
  }
}

Then calling that function will not degrade the performance of the rest of the function.

https://github.com/petkaantonov/bluebird/wiki/Optimization-killers#2-unsupported-syntax

roblabla avatar Mar 21 '16 10:03 roblabla