HTTP Result Code of load requests

Hello!

I’m doing some HTTP requests to load GLB models over the network, with this code:

BABYLON.SceneLoader.ImportMesh(null, '', tileUrl, this.scene,
              // onSuccess
              function(newMeshes, particleSystems, skeletons) {
              },
              // onProgress
              function(event) {
              },
              // onError
              function(event) {
              }
  )

My HTTP server uses different result codes (400, 404, 500…) to signal different cases that I’d need to display.

I cannot seem to find the result code in the onError event. Is there some way to access the HTTP Result code?

Check this: Babylon.js/fileTools.ts at ef09d779e70573410b0006a354612f16cfe1b5c1 · BabylonJS/Babylon.js · GitHub

The error is of type RequestFileError. It has a request property. And the request property contains status and statusText.

So this works for me. I am using async function.

try {
    const successOutcome = await BABYLON.SceneLoader.ImportMeshAsync(..., 'some invalid url');
} catch(error) {
    console.log(error.request.status);
}

It should be similar for ImportMesh.

// onError
function(error) {
    console.log(error.request.status);
}

Yes, thank you. I had missed entirely the other paramers, it turns out the error handler receives the exception.

This works now. Thanks a lot:

// onError
function(scene, msg, ex) {
                //console.log("Tile model (.glb) loading error: ", event);
                console.log("Tile model (.glb) loading error: ", ex.request.status);