Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix error stack handling #65

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open

Fix error stack handling #65

wants to merge 6 commits into from

Conversation

Srlion
Copy link

@Srlion Srlion commented Oct 8, 2024

Fixes #64

Works exactly the same how it worked before, but now it won't throw an error for not being able to get the stack correctly,

New message is:

[GLuaTest]: Test run starting...

[GLuaTest] === Running goobie_sql/sqlite.lua... ===
[GLuaTest] FAIL [love or hate, you gonna eat it]
    File:
       addons/goobie_sql/lua/tests/goobie_sql/sqlite.lua

    Context:
      _____________________________________________________________
     |
  17 | do return {
  18 |     cases = {
  19 |         {
  20 |             name = "love or hate, you gonna eat it",
  21 |             func = function()
  22 |                 ("s"):gsub("s", function() <- Unhandled
     |_____________________________________________________________



[GLuaTest] Test run complete! 🎉
[GLuaTest] Ran 1 tests from 1 test groups in 0.008 seconds
[GLuaTest] | PASS: 0
[GLuaTest] | FAIL: 1
[GLuaTest] | EMPT: 0
[GLuaTest] | SKIP: 0

Test failures:
=== goobie_sql/sqlite.lua ===
FAIL [love or hate, you gonna eat it]


[GLuaTest]: Test run complete!

@Srlion
Copy link
Author

Srlion commented Oct 8, 2024

Now it's in a good state, almost all error cases are handled. When a "case" function does something like this:

{
            name = "FetchOneSuccessAsync",
            func = function()
                return error("no!!")
            end
        },

There is no stack to get to tell where the error raised from, so we just point to the case's function:

Failed to get a stack, probably returning a function that errored! For example, 'return error('!')'
[GLuaTest] FAIL [FetchOneSuccessAsync]
    File:
       addons/goobie_sql/lua/tests/goobie_sql/fetchone.lua

    Context:
      _______________________________________________
     |
  29 |
  30 | cases = {
  31 |
  32 |     {
  33 |         name = "FetchOneSuccessAsync",
  34 |         func = function() <- Unhandled
     |_______________________________________________

if the case function changes to non tail call and errors

{
            name = "FetchOneSuccessAsync",
            func = function()
               error("no!!")
            end
        },
[GLuaTest] FAIL [FetchOneSuccessAsync]
    File:
       addons/goobie_sql/lua/tests/goobie_sql/fetchone.lua

    Locals:
       yes = true

    Context:
      _________________________________________________
     |
  31 |
  32 | {
  33 |     name = "FetchOneSuccessAsync",
  34 |     func = function()
  35 |         local yes = true
  36 |         error("no!!") <- Unhandled: no!!
     |_________________________________________________

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error when using "return" before error in gsub
1 participant