         data.layers.unshift type: "Basic"
       when 'CUSTOM' then Klass = Jax.Material
       when 'SURFACE', 'VOLUME', 'HALO', 'WIRE'
-        throw new Error "Material type #{data.type}: Not yet implemented."
+        throw new Error "#{name}: Material type #{data.type} is not yet implemented."
       else
-        throw new Error "Material property `type` is invalid. Please note that its meaning changed in Jax v2.1 and see documentation for details."
+        throw new Error "#{name}: Material property `type` is invalid. Please note that its meaning changed in Jax v2.1 and see documentation for details."
     Jax.Material.instances[name] = new Klass data, name
     
   @addResources: (resources) ->

      context.gl.drawElements mesh.draw_mode, buffer.length, buffer.dataType, 0
    else if (buffer = mesh.getVertexBuffer()) && buffer.length
      context.gl.drawArrays mesh.draw_mode, 0, buffer.length
      
    # @shader.disable context, @assigns
  
  @instances: {}
  @resources: {}

#= require_tree "./material"

class Jax.Material
  constructor: (options, @name = "generic") ->
    @shader = new Jax.Shader2.Program @name
    @layers = []
    @assigns = {}
    options = Jax.Util.normalizeOptions options, {}
