context_error 0.2.0

Library to create rich errors to help users understand what the error was and how to fix it
Documentation

πŸ¦€ Rust: Crates.io context_error documentation

Create nice error messages full of context

My take on creating nice error messages intended for both libraries and end user code. With a high amount of possible ways of adding more context for end users. This project started in pdbtx and then moved with all my new Rust projects but now finally has ended up in its very own crate.

Features

  • Supports rich context (file names, file numbers)
  • Supports multiple highlights in a single context
   ╭─[file.txt:42]
42 β”‚ Hello world
   β•Ž  ╢─╴╢╴⁃⁃
   β•΅
  • Supports multiline contexts
  • Supports comments on highlights
 β•·
 β”‚ Hello world
 β•Ž  β•Άβ•΄
 β”‚ Make it a good one!
 β•Ž      β•Άβ•΄Cool    ╢─╴1
 β•΅
  • Supports adding suggestions to the error message
error: Invalid path
 β•·
 β”‚ fileee.txt
 β•΅
This file does not exist
Did you mean any of: file.txt, filet.txt?
  • Supports merging multiple instances of the same error
  • Supports version tags in the error
error: Invalid number
   β•·
3  β”‚ null,80o0,YES,,67.77
   β•Ž      ╢──╴
13 β”‚ null,7oo1,NO,-1,23.11
   β•Ž      ╢──╴
35 β”‚ HOMOSAPIENS,12i1,YES,,1.23
   β•Ž             ╢──╴
   β•΅
This column is not a number
Version: Software AB v2025.42
  • Supports displaying the output with colours (controlled with a feature)
  • Supports displaying the output using only ascii characters (controlled with a feature)
  • Supports displaying the output as HTML

And most importantly it allows you to only define those properties that are known and make sense and slims down the output to always be neat.

License

EUPL