Skip to content

feat(router): add errorhandling functionality#153

Merged
EvandroLG merged 1 commit intoEvandroLG:masterfrom
Tieske:feat/errorhandling
Mar 5, 2026
Merged

feat(router): add errorhandling functionality#153
EvandroLG merged 1 commit intoEvandroLG:masterfrom
Tieske:feat/errorhandling

Conversation

@Tieske
Copy link
Contributor

@Tieske Tieske commented Mar 3, 2026

fixes #152 by adding errorhandling (and a confgurable errorhandler) to the router plugin

Here's example output (provided LuaLogging is installed)

Tue Mar  3 21:38:50 2026 DEBUG Handler created, without location
Pegasus is up on 0.0.0.0:9090
Tue Mar  3 21:38:50 2026 INFO Pegasus is up on 0.0.0.0:9090
Tue Mar  3 21:38:57 2026 INFO Request for: GET /api/1v0/people/John
Tue Mar  3 21:38:57 2026 DEBUG served John's data
Tue Mar  3 21:39:02 2026 INFO Request for: GET /api/1v0/people
Tue Mar  3 21:39:02 2026 ERROR Request for: GET /api/1v0/people, failed: example/app.lua:45: something really bad happend!!!!
stack traceback:
        [C]: in function 'error'
        example/app.lua:45: in field '?'
        ./src/pegasus/plugins/router.lua:297: in function <./src/pegasus/plugins/router.lua:272>
        [C]: in function 'xpcall'
        ./src/pegasus/plugins/router.lua:328: in function 'pegasus.plugins.router.newRequestResponse'
        ./src/pegasus/handler.lua:132: in function 'pegasus.handler.pluginsNewRequestResponse'
        ./src/pegasus/handler.lua:255: in function 'pegasus.handler.processRequest'
        ./src/pegasus/init.lua:118: in function 'pegasus.start'
        example/app.lua:119: in main chunk
        [C]: in ?
Tue Mar  3 21:39:07 2026 INFO Request for: GET /api/1v0/people/John
Tue Mar  3 21:39:07 2026 DEBUG served John's data

Copy link
Owner

@EvandroLG EvandroLG left a comment

Choose a reason for hiding this comment

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

Looks great, thanks! :)

@EvandroLG EvandroLG merged commit 52b480a into EvandroLG:master Mar 5, 2026
0 of 6 checks passed
@scossu
Copy link

scossu commented Mar 6, 2026

Wonderful. Are you planning to release a new version soon?

@EvandroLG
Copy link
Owner

@scossu I just released a new version with the fix implemented by @Tieske
Thanks guys!

@Tieske Tieske deleted the feat/errorhandling branch March 6, 2026 20:13
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.

How to handle errors

3 participants