Skip to content

Recover subject name when called with pcall to get proper error messages#102

Open
RaphaelIT7 wants to merge 2 commits intoCFC-Servers:mainfrom
RaphaelIT7:patch-18
Open

Recover subject name when called with pcall to get proper error messages#102
RaphaelIT7 wants to merge 2 commits intoCFC-Servers:mainfrom
RaphaelIT7:patch-18

Conversation

@RaphaelIT7
Copy link
Copy Markdown
Collaborator

This disastrous abomination of unholy code solves the current issue CFC-Servers/gmod_tests#25 is having
When you pass a function to pcall that will error directly, Lua has no idea what the name of it is, causing the error message to include '?' instead of for example 'Left'
This tries to fix that issue, it's bad, but it works really well in my testing.

And no, simply using debug.getinfo to get the name does not work, as the name will not be set for the subject so I fell back to reading the file to figure out the name :/
There probably is a better way, though this is the best that I came up, it may be a disaster, but it's a functional one :3

@RaphaelIT7 RaphaelIT7 force-pushed the patch-18 branch 4 times, most recently from 9ce7b8f to 75841f5 Compare October 27, 2025 11:38
Copy link
Copy Markdown
Member

@sarahsturgeon sarahsturgeon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lol this is wild

@sarahsturgeon sarahsturgeon self-assigned this Apr 7, 2026
Copy link
Copy Markdown
Member

@sarahsturgeon sarahsturgeon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I want to give this some more thought to figure out if this is the right way (or best short-term way) to approach this. Regardless, if we do go this way, I'd like to see some LuaLS typedocs for these functions. They're complex enough that having annotations could really help the reader understand.

@RaphaelIT7 RaphaelIT7 force-pushed the patch-18 branch 2 times, most recently from 0447514 to b5074cb Compare April 14, 2026 21:02
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.

2 participants