Adding error handler for assets.loadFromUrlAndFilename?

It is easy to get lost in code for a newbie like me, in which line should I add error handler if there are any errors while parsing the file (err) ?
console.log('Model failed to load')

Thanks in advice

  entity = new pc.Entity('Model');
   pc.app.root.addChild(entity);
    pc.app.assets.loadFromUrlAndFilename(modelurl, null, "container", function (err, asset) {
        // Add the loaded scene to the hierarchy
        entity.addComponent('model', {
            asset: asset.resource.model
        });

               entity.addComponent('collision', {
        type: 'mesh',
         asset: asset.resource.model
    });
    
   entity.addComponent('rigidbody', {
        type: pc.BODYTYPE_KINEMATIC
    });
         
        if (asset.resource.animations.length > 0) {
            entity.addComponent('animation', {
                assets: asset.resource.animations    
            });
        }

        entity.aabb = new pc.BoundingBox();

        var meshes = entity.model.model.meshInstances;
if (meshes.length) {
    entity.aabb.copy(meshes[0].aabb);
    for(var i = 1; i < meshes.length; i++)
        entity.aabb.add(meshes[i].aabb);
        console.log(meshes);
        x = entity.aabb.halfExtents.x * 2;
        console.log(x);
        y = entity.aabb.halfExtents.y * 2;
        console.log(y);
        z = entity.aabb.halfExtents.z * 2;
        console.log(z);        
       

var meshInstances = entity.model.meshInstances;
var mat;
var total = 0;
for (var i2 = 0; i2 < meshInstances.length; i2++) {
    //  mat = meshInstances[i].mesh.vertexBuffer.numVertices;
    mat = parseFloat(meshInstances[i2].mesh.indexBuffer[0].numIndices / 3);
    total += mat;
}
console.log(total);



         
}
});

The goal is to prevent crashing/executing the whole piece of code if error occurs

pc.app.assets.loadFromUrlAndFilename(modelurl, null, "container", function (err, asset) {
      if (err) {
        console.log('Model failed to load');
      } else {

Still getting global error if the file is not found wrong launch.js:15193 SyntaxError: Unexpected token < in JSON at position 0

Or it would not be shown in compiled game?

Hmm, the error handler should have caught it. Can you put together a smaller public example of the issue and if it’s a bug, we can add it to the engine issue tracker