Skip to content

Instantly share code, notes, and snippets.

@Doy-lee
Doy-lee / error_handling_using_a_sink.md
Last active February 11, 2024 11:04
Error handling using a 'sink'

Error Handling using a 'sink'

Error sinks are a way of accumulating errors from API calls related or unrelated into 1 unified error handling pattern. The implementation of a sink requires 2 fundamental design constraints on the APIs supporting this pattern.

  1. Pipelining of errors

    Errors emitted over the course of several API calls are accumulated into a sink which save the error code and message of the first error encountered

@Doy-lee
Doy-lee / clang_merge_compilation_command_files.bat
Created June 27, 2022 13:10
Merge clang compilation command files (i.e. clang -MJ) into compile_command.json compatible files using pure Windows batch
@echo off
REM NOTE: Overview (Version 1)
REM ----------------------------------------------------------------------------
REM
REM Merge multiple compilation command files generated by clang -MJ and dump it
REM to standard output as a JSON array. This script lets you merge the output
REM files clang dumps on execution of this command without relying on any
REM external tools, just pure batch scripting.
REM
REM An entry generated by clang -MJ, looks like this:
@Doy-lee
Doy-lee / generate_msvc17_toolchain.bat
Last active July 29, 2020 05:38
Generate Self-Contained MSVC 2017 Toolchain
REM
REM Generate Standalone MSVC17 x86/x64 Toolchain from VS Installation
REM
REM Collects the necessary includes, binaries, DLLs and libs to around ~300mb on
REM disk from a VS installation that can invoke cl, and link as you typically
REM would after calling "vcvarsall.bat x64"
REM
REM This script generates the helper scripts within the generated toolchain.
REM cl_[x64|x86].bat: Invokes the compiler with required environment variables set
REM link_[x64|x86}.bat: Invokes the linker with required environment variables set