<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Rust on Cheat Sheet</title><link>/tags/rust/</link><description>Recent content in Rust on Cheat Sheet</description><generator>Hugo</generator><language>en</language><atom:link href="/tags/rust/index.xml" rel="self" type="application/rss+xml"/><item><title>Error Handling</title><link>/programming/cpp/advanced/error-handling/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>/programming/cpp/advanced/error-handling/</guid><description>&lt;h1 id="error-handling-in-c-abseil-status-statusort--gorust-comparison"&gt;Error Handling in C++: Abseil &lt;code&gt;Status&lt;/code&gt;, &lt;code&gt;StatusOr&amp;lt;T&amp;gt;&lt;/code&gt; &amp;amp; Go/Rust Comparison&lt;a class="anchor" href="#error-handling-in-c-abseil-status-statusort--gorust-comparison"&gt;#&lt;/a&gt;&lt;/h1&gt;
&lt;p&gt;This article explains why large-scale C++ codebases favor &lt;strong&gt;value-based error handling (Errors as Values)&lt;/strong&gt; over C++ exceptions (&lt;code&gt;try-catch&lt;/code&gt;), how to use open-source &lt;strong&gt;Abseil (&lt;code&gt;abseil-cpp&lt;/code&gt;)&lt;/strong&gt; types &lt;code&gt;absl::Status&lt;/code&gt; and &lt;code&gt;absl::StatusOr&amp;lt;T&amp;gt;&lt;/code&gt;, and how this design maps directly to &lt;strong&gt;Go&amp;rsquo;s &lt;code&gt;(T, error)&lt;/code&gt;&lt;/strong&gt;, &lt;strong&gt;Rust&amp;rsquo;s &lt;code&gt;Result&amp;lt;T, E&amp;gt;&lt;/code&gt;&lt;/strong&gt;, and &lt;strong&gt;C++23&amp;rsquo;s &lt;code&gt;std::expected&amp;lt;T, E&amp;gt;&lt;/code&gt;&lt;/strong&gt;.&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id="1-why-large-scale-c-projects-avoid-exceptions-try-catch"&gt;1. Why Large-Scale C++ Projects Avoid Exceptions (&lt;code&gt;try-catch&lt;/code&gt;)&lt;a class="anchor" href="#1-why-large-scale-c-projects-avoid-exceptions-try-catch"&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Although standard C++ supports &lt;code&gt;throw&lt;/code&gt; and &lt;code&gt;try-catch&lt;/code&gt;, many large production C++ codebases (following the &lt;a href="https://google.github.io/styleguide/cppguide.html#Exceptions"&gt;Google C++ Style Guide&lt;/a&gt;) disable exceptions via &lt;code&gt;-fno-exceptions&lt;/code&gt; and rely on &lt;strong&gt;explicit error return values&lt;/strong&gt;.&lt;/p&gt;</description></item></channel></rss>