DuskSystems / wayfind

A speedy, flexible router for Rust.
Apache License 2.0
8 stars 0 forks source link

Improve error messages #114

Closed CathalMullan closed 2 months ago

CathalMullan commented 2 months ago

WIP

Ideally, adding nice errors should result in no performance impact for valid usage. In reality, I'm willing to take a small hit to performance for better errors.

Maybe a little verbose.

duplicate constraint name

The constraint name 'my_constraint' is already in use:
    - existing constraint type: 'errors::ConstraintA'
    - new constraint type: 'errors::ConstraintB'

help: each constraint must have a unique name

try:
    - Check if you have accidentally added the same constraint twice
    - Ensure different constraints have different names
invalid percent-encoding

   Input: /hello%20world%GG
                        ^^^

Expected: '%' followed by two hexadecimal digits (a-F, 0-9)
   Found: '%GG'

Concerned with inconsistent language. Need to find some sort of guide (maybe from the Rust devs?) around writing long-form error messages.

EDIT: This is growing quite large. May not finish all updates in this single PR.

Also, the leading error: ... seems redundant. Removed.

We can iterate on these over time.

codspeed-hq[bot] commented 2 months ago

CodSpeed Performance Report

Merging #114 will not alter performance

Comparing 59-improved-error-messages (5f6316b) with main (94cfc4b)

Summary

✅ 16 untouched benchmarks