Rust Error Handling

Error handling is hard rusts error handling is substantially different from other languages. For a quick comparison let’s look at a python example: try: # code that fails except: # what happens when code fails This approach, although intuitive, leaves some important flaws. Namely: Unhandled errors may occur Errors are propagated implicitly, not explicitly, which can lead to some unwanted behavior If your try-block ends up containing multiple parts of code that could fail you have to handle each of them separately How rust handles errors If you have used rust before you’ll already know what comes up....

May 5, 2024 · Moritz Sokoll

skvconf - A configuration file parser

Introduction I have been programming in various languages for quite some time now but have found myself coming back to C and rust the most. One small problem I had with C however was adding configuration capabilities to my applications. In rust I always just used the toml crate but that didn’t work in C. So I ended up writing very simple parsers for these projects. This was of course not very scalable and also had ugly configuration syntax as a side effect....

April 21, 2024 · Moritz Sokoll

Writing a web server in C

Introduction A while ago I started work on a web server written in C. The project is available here. Before I had written a web server in rust (found here) so I was a bit familiar with HTTP and since this wasn’t my first ever C project I of course knew a bit about basic file handling and error handling. The main new things to learn where the following: Working with sockets Using a thread pool with: Worker threads An event queue for incoming requests Parsing a configuration file Technical details Sockets While I was somewhat familiar with sockets I hadn’t used them in C (I used them in a small python web server)....

April 17, 2024 · Moritz Sokoll