#with_context
A simple way of handling errors in Rust using the anyhow crate
November 25, 2025 at 4:01 PM
god bless anyhow and with_context. Genuinely makes getting ~90% of the way to actually production-quality CLI error messages with minimal effort possible.
March 26, 2025 at 3:52 PM
this = fail_whale.integrate_where { |w| w.memories.select { |e| e.product.aligns_with(EMOTIONS.SHAME.product) }.nudge_with(EMOTIONS.CURIOSITY.product).by_pct(1).with_context('failure is how we learn, we should delight in its presence for we have created opportunity from nothing')
February 5, 2026 at 2:36 PM
with_context tutorial explains how to dynamically manage context in Odoo for translations, default values, and multi-company settings. Enhance your Odoo development skills and streamline record management. #Odoo #with_context #Tutorial #OdooDev
with_context in Odoo: Enhance Your Environment Settings
with_context in Odoo is a powerful tool that you use to modify function behavior dynamically. In this tutorial, you learn how to implement with_context in Odoo to control translations, default values, multi-company behavior, and other settings. You also discover how the Odoo context, maintained as a dictionary, can transform your recordsets without permanently altering them. You will actively follow our step-by-step code examples and explanations as you master context management in Odoo.
teguhteja.id
March 10, 2025 at 1:06 PM
Returning the result of result revisited
Please consider this: #1 with `collect()` use anyhow::{Context, Result}; #[allow(unused_imports)] use std::{ fmt::Display, fs::File, io::{self, BufRead, BufReader}, panic::Location, path::Path, }; type Gizmo = Result<io::Result<Vec<String>>>; fn slurp(path: impl AsRef<Path> + Display) -> Gizmo { let file = File::open(&path) .with_context(|| format!("Failed to open `{path}` at {}", Location::caller()))?; let buffer = BufReader::new(file); let lines = buffer.lines().collect(); Ok(lines) } fn main() -> Result<()> { let path = "test.dat"; if let Ok(lines) = slurp(&path)? { for line in lines { println!("{} ", line); } } Ok(()) } #2 with `push()` type Gizmo = Result<Vec<String>>; fn slurp(path: impl AsRef<Path> + Display) -> Gizmo { let file = File::open(&path) .with_context(|| format!("Failed to open `{path}` at {}", Location::caller()))?; let buffer = BufReader::new(file); let mut lines = Vec::new(); for line in buffer.lines(){ lines.push(line?); } Ok(lines) } fn main() -> Result<()> { let path = "test.dat"; if let Ok(lines) = slurp(&path) { for line in lines { println!("{} ", line); } } Ok(()) } How can i avoid to return a result of a result (like in version #2) using `collect()`(and therefore `slurp(&path)?` in `main`) in version #1?
users.rust-lang.org
April 11, 2025 at 10:01 AM
Rust error handling reference covering thiserror vs anyhow and when to use each

thiserror for library crates (derive + #[from] for automatic From impl), anyhow for binaries (context() vs with_context(), bail!, downcast_ref)

also has the panic vs Result decision guide
March 29, 2026 at 8:23 AM