RobLoach / node-raylib

Node.js bindings for Raylib
https://robloach.github.io/node-raylib/
Other
242 stars 20 forks source link

Return null on Load fail #79

Closed RobLoach closed 3 years ago

RobLoach commented 3 years ago

When an object fails to load, return a null object?

const raw = fs.readFileSync('wabbits_alpha.png');
const imgBunny = r.LoadImageFromMemory('png', raw, raw.length);
if (! imgBunny.data) {
  console.error('failed to load image!');
  process.exit(1);
}

const texBunny = r.LoadTextureFromImage(imgBunny);
if (! texBunny.id) {
  console.error('failed to load texture!');
  process.exit(1);
}