frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

Open in hackernews

Show HN: Stack Error – ergonomic error handling for Rust

https://github.com/gmcgoldr/stackerror
18•garrinm•3h ago
Stack Error reduces the up-front cost of designing an error handling solution for your project, so that you focus on writing great libraries and applications.

Stack Error has three goals:

1. Provide ergonomics similar to anyhow.

2. Create informative error messages that facilitate debugging.

3. Provide typed data that facilitates runtime error handling.

Comments

tevon•2h ago
This is awesome! Will give it a try in my next project.

How does it keep track of filename and line number in a compiled binary? I'm fairly new to rust libraries and this doesn't quite make sense to me. I know in JS you need a source-map for minification, how does this work for a compiled language?

fpoling•2h ago
Rust provides file!, line! and column! macros that expands into a compile-time constants that the compiler embeds then into the executable. This way no source map at runtime is necessary as the relevant errors are constructed from those constants.

Presumably StackError just uses those macros.

But for debugging a source map is still necessary and is a part of various debug formats.

rhabarba•2h ago
I still prefer the Anyhow solution, but I like the approach here.
IshKebab•1h ago
Isn't this strictly superior to Anyhow? What do you like more about Anyhow?
shepmaster•1h ago
I hope to read through your crate and examples later, but if you have a chance, I’d be curious to hear your take on how Stack Error differs from my library, SNAFU [1]!

[1]: https://docs.rs/snafu/latest/snafu/index.html

lilyball•37m ago
If the macros only exist to get file and line information, you could do the same thing by using `#[track_caller]` functions combined with `std::panic::Location` to get that same info. For example, `stack_err!` could be replaced with

  impl StackError {
      #[track_caller]
      fn new_location(msg: impl Display) -> Self {
          let loc = std::panic::Location::caller();
          Self::new(format!("{}:{} {msg}", loc.file(), loc.line()))
      }
  }
such that you call `.map_err(StackError::new_location("data is not a list of strings"))`. A macro is nice if you need to process format strings with arguments (though someone can call `StackError::new_location(format_args!(…))` if they want), but all of your examples show static strings so it's nice to avoid the error in that case.

The use of `std::panic::Location` also means instead of baking that into a format string you could also just have that be an extra field on the error, which would let you expose accessors for it, and you can then print them in your Debug/Display impls.

Speaking of, the Display impl really should not include its source. Standard handling for errors expects that an error prints just itself with Display because it's very common to recurse through sources and print those, so if Display prints the source too then you're duplicating output. Go ahead and print it on Debug though, that's nice for errors returned from `main()`.

France Becomes First Government to Endorse UN Open Source Principles

https://social.numerique.gouv.fr/@codegouvfr/114529954373492878
1•bzg•30s ago•0 comments

The Neglected Abundance of Your Backyard

https://www.noemamag.com/the-neglected-abundance-of-your-backyard/
1•marojejian•1m ago•0 comments

Increased sitting assoc with neurodegeneration & worse cognition in older adults

https://alz-journals.onlinelibrary.wiley.com/doi/10.1002/alz.70157
1•bookofjoe•6m ago•0 comments

Augmented Coding: Better with Principles

https://jessitron.com/2025/05/18/augmented-coding-better-with-principles/
1•ingve•9m ago•0 comments

Transforming Productivity: How AI Fixed the Human Problem in Software Dev

https://blog.fka.dev/blog/2025-05-19-transforming-productivity-how-ai-fixed-the-human-problem-in-software-development/
1•fka•10m ago•0 comments

Telegram CEO: French intelligence head asked me to ban Romanian conservatives

https://twitter.com/durov/status/1924187940122431572
9•like_any_other•12m ago•1 comments

Microsoft has disabled the ICC Chief prosecutors email account

https://twitter.com/liamcunningham1/status/1924120334598385821
9•notRobot•15m ago•2 comments

FSRS (Free Spaced Repetition Scheduler)

https://github.com/open-spaced-repetition/fsrs4anki/wiki/ABC-of-FSRS
1•Bluestein•18m ago•0 comments

Coinbase Gets Hacked

https://techcrunch.com/2025/05/17/techcrunch-week-in-review-coinbase-gets-hacked/
1•badmonster•18m ago•1 comments

I replaced Superhuman, Motion, and Notion with a 300-line script

https://www.merlin.computer/
5•thielgary•19m ago•0 comments

Quantum Country

https://quantum.country
2•agarttha•20m ago•0 comments

LLM Throws Syntax Error Tantrum: Teaching AI to Craft Graph Style Scripts (2024)

https://memgraph.com/blog/llm-throws-syntax-error-tantrum-teaching-ai-graph-style-script
1•LLcolD•21m ago•0 comments

Memory Safety in Chapel

https://chapel-lang.org/blog/posts/memory-safety/
1•yubblegum•24m ago•0 comments

Weddingeddon

https://weddingeddon.com/
4•jseip•27m ago•1 comments

The art of cold emailing a billionaire

https://wanderingfounder.substack.com/p/the-art-of-cold-emailing-a-billionaire
3•andylee024•29m ago•0 comments

Unlimited text-to-speech using Kokoro-JS, 100% local, 100% open source

https://streaming-kokoro.glitch.me/
4•raymond_goo•31m ago•1 comments

How to optimise latency when building voice agents?

https://comparevoiceai.com/blog/latency-optimisation-voice-agent
2•whoami_nr•32m ago•0 comments

AI agents in 2025 – what everyone's getting wrong

https://old.reddit.com/r/AI_Agents/comments/1knch0r/ai_agents_in_2025_what_everyones_getting_wrong/
4•shenli3514•37m ago•0 comments

Show HN: DoodleDreamer – Bring your imagination to life

https://twitter.com/Jaw9c/status/1924219453249663051
1•joshwarwick15•37m ago•0 comments

U.S. Downgraded by Moody's as Trump Pushes Costly Tax Cuts

https://www.nytimes.com/2025/05/16/business/us-credit-downgrade-moodys.html
6•whack•42m ago•0 comments

OpenAI Prompting Guide

https://cookbook.openai.com/examples/gpt4-1_prompting_guide
1•RyanShook•44m ago•0 comments

His Life Savings Were Mailed to Him by Paper Check. Now, It's Gone

https://www.nytimes.com/2025/05/17/business/paychex-401k-rollover-checks.html
7•littlexsparkee•46m ago•3 comments

Decades-long mystery of ginger cats revealed

https://www.bbc.com/news/articles/cwywdjjgvqqo
1•gmays•47m ago•0 comments

Ask HN: Best on device LLM tooling for PDFs?

1•martinald•49m ago•1 comments

Embracing Slow Tech

https://btxx.org/posts/slow/
1•CppPro•54m ago•0 comments

Lines of Code

https://linesofcode.yehiaabdelm.com/
1•thunderbong•55m ago•0 comments

YouTube's new ads will ruin the best part of a video on purpose

https://www.androidauthority.com/youtube-peak-points-ads-3557905/
9•namanyayg•56m ago•5 comments

Largest database of nanosatellites, over 4400 nanosats and CubeSats

https://www.nanosats.eu
1•namanyayg•56m ago•0 comments

Collatz's Ant and Similarity of Landscapes

https://gbragafibra.github.io/2025/05/18/collatz_ant3.html
1•Fibra•57m ago•0 comments

Show HN: A Wolfenstein3D-like raycaster made in Windows Batch

https://github.com/nTh0rn/batch-raycaster
2•nthornton•1h ago•0 comments