Is there a way to catch any uncaught errors? (SOLVED)

Is there a way to catch any uncaught errors with my own function?

4 Likes

Thanks, this is exactly what I need!

Update: this function is not called when shader compilation error occurs

The function is called at runtime when an error is thrown in your Lua code. I believe this is stated in the API docs.

Can you tell us a bit more about the shader error? I would have thought that we would detect most errors when we run the shader through SPIR-V.

Many, but not all, since each graphics driver may interpret the glsl source code slightly different in some cases.

Perhaps we can get to see the error and/or the shader that fails?
What platform is it? Graphics card?

1 Like

As an example, for test, I add

#version 130

to the beginning of shader.
This shader works on PC (Windows 8.1, Radeon 7770), but fails on Android.
Function didnt called.

It’ll probably be a lot easier if you shared the shader code with us.

Also, since you’re on Android, what does the logcat say?

Logcat say:

WARNING:GRAPHICS: 0:1: P0007: Language version ‘130’ unknown, this compiler only supports up to version ‘320 es’

My question is not about how to make shader, I especially make it incorrect to see an error. I want to say that function sys.set_error_handler didnt catch (almost?) any error in shaders, on Windows and Android.

Documentation for sys.set_error_handler():

Set the Lua error handler function. The error handler is a function which is called whenever a lua runtime error occurs.

As Björn mentioned earlier (and as seend in the example code), this function is designed exclusively to handle Lua errors, nothing more.

Can you describe what you’d wish to do if you got a callback with a shader compiler error?

As like any other errors, show it on screen or send it to my server. Who knows, maybe some devices for some reasons cant compile shader and throw error. When error is not processed, game just stuck.

1 Like