gl-format-compiler-error
Formats a webgl glsl compiler error. Use in conjunction with glsl-shader-name to include your shader's name in the formatted error string.
Example
var formatCompilerError = ; ... var shader = gl gl gl if!gl var errLog = gl var fmt = ; console; throw fmtshort;
yields warning:
Error in vertex shader generic: 13: 14: void main() { 15: bug;^^^^: 'bug' : undeclared identifier 17: vUV = aUV; 18: vPos = vec3(uModel * vec4(aPosition, 1.0)) 19: }^^^^: '}' : syntax error
and error:
Uncaught Error: Error in vertex shader generic:ERROR: 0:15: 'bug' : undeclared identifier ERROR: 0:19: '}' : syntax error
Usage
Install
npm install gl-format-compiler-error --save
API
var formatCompilerError = ;
fmt = formatCompilerError(errLog, source, type)
Takes errLog
result from gl.getShaderInfoLog
, the shader source
string, and the type
of shader,
either gl.VERTEX_SHADER
or gl.FRAGMENT_SHADER
. Returns an object that contains the long and short
form of the formatted error:
long: "long form error with code snippets" short: "short form error, similar to the original error log"