premake / premake/premake-core

Make token / detoken errors more verbose

Open
#702 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
C
Stars
3.6k
Forks
654
Avg merge
1d 1h
Merged PRs (30d)
13

Description

Debugging token issues such a missing ones can be quite a pain, so after failing to see the issue of my script using debug build (stacktrace) and even --scripts I've decided to add this following code piece to the error string on the detoken functions:

error(err .. " in token: " .. token .. "\npossible tokens:\n" .. table.tostring(e, 1), 0)
...
error("Token returned nil, it may not exist: " .. token .. "\npossible tokens:\n" .. table.tostring(e, 1), 0)

suddenly things made sense and I was able to easily fix my script. (hint: cfg didn't even exist in the context I was using it in)

So why didn't I just make a PR you ask?
Because this is a quick dirty hack and could use some work, as you can quickly grasp by looking at the output:
console output

But it's a start, it's better than the cryptic error message you can see in the upper part of the output...

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the detoken functions and reading how their current error strings expose missing or nil tokens. Reproduce the issue with a debug build and --scripts, then improve the diagnostic output so the failing token and possible tokens are readable; verify the resulting message against the reported cryptic output.

Written by the indexing model from the issue text.

Assessment

Tech stack
lua
Domain
build-system, tooling
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.