<?xml version="1.0" encoding="UTF-8"?><?xml-stylesheet href="/custom-pretty-feed-v3.xsl" type="text/xsl"?><rss version="2.0"><channel><title>Kristoffer Balintona — #Error handling</title><description>Entries tagged with &quot;Error handling&quot;</description><link>https://kristofferbalintona.me/</link><language>en-us</language><image><url>https://kristofferbalintona.me/favicon-rss.png</url><title>Kristoffer Balintona — #Error handling</title><link>https://kristofferbalintona.me</link></image><item><title>Guile Exceptions</title><link>https://kristofferbalintona.me/posts/202607230142/</link><guid isPermaLink="true">https://kristofferbalintona.me/posts/202607230142/</guid><description>&lt;p&gt;Learning Guile has been on my wishlist for a while because of the power it affords users of Guix: you get to control its service manager, Shepherd&lt;sup&gt;&lt;a href=&quot;#fn-1&quot;&gt;[1]&lt;/a&gt;&lt;/sup&gt;, configure other programs, manage containers&lt;sup&gt;&lt;a href=&quot;#fn-2&quot;&gt;[2]&lt;/a&gt;&lt;/sup&gt;, all in the same powerful language in a consistent syntax. But Guile is also a power language all on its own, too. You can write standalone program with it happily (and integrate it with your Guix config seamlessly).&lt;/p&gt;
&lt;p&gt;I recently found my first excuse to dive into the language itself (not just for Guix). My idea was to have a small, personal web server with a &lt;a href=&quot;https://en.wikipedia.org/wiki/REST#Applied_to_web_services&quot;&gt;RESTful API&lt;/a&gt;&lt;sup&gt;&lt;a href=&quot;#fn-3&quot;&gt;[3]&lt;/a&gt;&lt;/sup&gt; that lets me run, stop, and see the status and output of pre-defined tasks. I read the &lt;a href=&quot;https://doc.guix.gnu.org/guile/latest/en/html_node/Web.html&quot;&gt;relevant pages in Guile’s manual&lt;/a&gt; many times and within a few days got something that was acceptable (though I’ll no doubt refine, refactor, and add to it as time passes).&lt;/p&gt;
&lt;p&gt;One of the cool things I encountered with Guile were its exceptions. I’m not a programmer by trade and haven’t used many languages before, so I was mostly only familiar with “error = program implodes.” I found out Guile obviously has &lt;code&gt;error&lt;/code&gt;, but it also has &lt;a href=&quot;https://doc.guix.gnu.org/guile/latest/en/html_node/Exceptions.html&quot;&gt;quite rich exceptions&lt;/a&gt;. The older system was just &lt;code&gt;try&lt;/code&gt; + &lt;code&gt;catch&lt;/code&gt;, but the more modern 2019+ set of features is based on records (I think), has hierarchies, and more powerful “catching.”&lt;/p&gt;
&lt;p&gt;It was quite hard to wrap my mind around it enough to even just get off the ground, but I found these two articles very helpful, alongside the Guile manual pages on exceptions:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://vijaymarupudi.com/blog/2022-02-13-error-handling-in-guile.html&quot;&gt;Error handling in GNU Guile | Vijay Marupudi&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://andreashohmann.com/guile-exceptions/&quot;&gt;Guile exceptions | Andreas Hohmann&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;footer&gt; &lt;h2&gt;Footnotes &lt;a href=&quot;#footnotes-heading&quot;&gt;  
§
&lt;/a&gt;&lt;/h2&gt; &lt;ol&gt; &lt;li&gt;  &lt;a href=&quot;#fnref-1&quot;&gt;[1]&lt;/a&gt; &lt;div&gt; &lt;p&gt;Actually, I’ve also just recently learned (or realized) that Shepherd itself is quite decoupled from Guix. It wasn’t a natural thought to have because I’ve only ever indirectly run a service manager, through launching my system with it, whether Shepherd through Guix or Systemd through most Linux distros. But the way Shepherd is configured in Guix is, really, &lt;em&gt;just Shepherd configured in Guile&lt;/em&gt;. So I think you could technically do all sorts of cool things with Shepherd, either alone or alongside an existing running Shepherd or Systemd instance. I even learned that you can &lt;a href=&quot;https://doc.guix.gnu.org/shepherd/latest/en/shepherd.html#Jump-Start-1&quot;&gt;load new services live into a running Shepherd process&lt;/a&gt; and that there’s a Shepherd service for &lt;a href=&quot;https://doc.guix.gnu.org/shepherd/latest/en/shepherd.html#REPL-Service&quot;&gt;having a REPL to interact with Shepherd live&lt;/a&gt;!&lt;/p&gt;  &lt;a href=&quot;#fnref-1&quot;&gt;↩&lt;/a&gt; &lt;/div&gt; &lt;/li&gt;&lt;li&gt;  &lt;a href=&quot;#fnref-2&quot;&gt;[2]&lt;/a&gt; &lt;div&gt; &lt;p&gt;I’ve been using it for months to manage my self-hosted services at home. I have dozens of podman containers run through Shepherd.&lt;/p&gt;  &lt;a href=&quot;#fnref-2&quot;&gt;↩&lt;/a&gt; &lt;/div&gt; &lt;/li&gt;&lt;li&gt;  &lt;a href=&quot;#fnref-3&quot;&gt;[3]&lt;/a&gt; &lt;div&gt; &lt;p&gt;It was my first time implementing a REST API myself, too. (Actually: I hadn’t ever worked to directly implement an HTTP server before at all.) The best resources I found on the right approach to designing a REST API came from &lt;a href=&quot;https://restfulapi.net/&quot;&gt;https://restfulapi.net/&lt;/a&gt;.&lt;/p&gt;  &lt;a href=&quot;#fnref-3&quot;&gt;↩&lt;/a&gt; &lt;/div&gt; &lt;/li&gt; &lt;/ol&gt; &lt;/footer&gt;</description><pubDate>Thu, 23 Jul 2026 01:42:00 GMT</pubDate><category>Guile</category><category>Error handling</category></item></channel></rss>