Skip to content

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!!
     |_________________________________________________

@sarahsturgeon
Copy link
Member

sarahsturgeon commented Apr 12, 2025

Hey @Srlion

Thanks for this fix - I was hoping to get it into the 0.33 update, but unfortunately I had to introduce some conflicts.

Would you be open to fixing those? I might be able to do it and push to your branch, if you prefer.

Thanks for your patience, and thanks again for the fix ❤️

@Srlion
Copy link
Author

Srlion commented Apr 12, 2025

Hey!! I think I can look into it next week just because I don't want to resolve the conflicts without testing shady cases :X If you don't want to wait you can resolve them, I don't mind. Thanks for your work <3

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

2 participants