{"id":25393895,"url":"https://github.com/5cover/c-exceptions","last_synced_at":"2025-10-30T19:31:36.580Z","repository":{"id":56775900,"uuid":"524651220","full_name":"5cover/C-exCeptions","owner":"5cover","description":"Macros for throwing and handling exceptions in C, in a try/catch/finally-like fashion.","archived":false,"fork":false,"pushed_at":"2023-07-04T17:51:35.000Z","size":137,"stargazers_count":2,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2023-07-04T18:31:13.363Z","etag":null,"topics":["c","exception","exception-handling","exceptions","try-catch","try-catch-finally"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/5cover.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-08-14T11:27:15.000Z","updated_at":"2023-07-04T17:53:51.000Z","dependencies_parsed_at":"2023-01-20T07:20:40.888Z","dependency_job_id":null,"html_url":"https://github.com/5cover/C-exCeptions","commit_stats":null,"previous_names":[],"tags_count":null,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/5cover%2FC-exCeptions","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/5cover%2FC-exCeptions/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/5cover%2FC-exCeptions/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/5cover%2FC-exCeptions/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/5cover","download_url":"https://codeload.github.com/5cover/C-exCeptions/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239040691,"owners_count":19572032,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["c","exception","exception-handling","exceptions","try-catch","try-catch-finally"],"created_at":"2025-02-15T18:54:14.905Z","updated_at":"2025-10-30T19:31:31.275Z","avatar_url":"https://github.com/5cover.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# C-exCeptions\n\nStatic library containing macros for throwing and handling exceptions in C based on the C# syntax.\n\nUnhandled exceptions result in a call to ``abort()``.\nTo respond to unhandled exceptions, the ``SIGABRT`` signal can be handled or a *try/catchAll* block can be defined in the main function.\n\n## Usage\n\nInterface reference:\n\n- ``throw``: throw an exception\n    1. *id* - ID of the exception. Can be an ``ExceptionID`` value or an integer.\n    2. *message* - Message of the exception. Must be a string (``char *``).\n- ``try``: define a try block\n- ``catch``: catch an exception with a specific ID\n    1. *targetId* - ID of the exception to catch. Can be an ``ExceptionID`` value or an integer.\n    2. *varName* - Name of the variable (of type ``Exception const *const``) that points the catched exception.\n- ``catchWhen``: catch an exception with a specific ID only when the provided boolean expression evaluates to true\n    1. *targetId* - ID of the exception to catch. Can be an ``ExceptionID`` value or an integer.\n    2. *varName* - Name of the variable (of type ``Exception const *const``) that points the catched exception.\n- ``catchAll``: catch any exception\n    1. *varName* - Name of the variable (of type ``Exception const *const``) that points the catched exception.\n- ``catchAllWhen``: catch any exception when the provided boolean expression evaluates to true\n    1. *varName* - Name of the variable (of type ``Exception const *const``) that points the catched exception.\n- ``rethrow``: rethrow an exception from a catch block.\n- ``finally``: defines a block to execute regardless of whether an exception occured or not.\n\nSee the comments in [example](https://github.com/5cover/C-exCeptions/blob/main/example/main.c) for a walk-through of the code.\n\n## Known issues\n- The ``try`` macro cannot be used in a single-statement scope (*i.e.* ``if`` statement without braces). This is not a problem since it is useless without *catch* or *finally* blocks.\n- An exception variable name has to be specified when defining a *catch* block. You can use ``_`` as the identifier if you're not planning to use it. Unused variable warnings will be hidden if GNU C is supported (with the ``unused`` attribute).\n- The try-catch stack is defined as thread-local, so exceptions will not bubble up outside of their original thread.\n\n## Reserved identifiers\n\nAll reserved identifiers are prefixed by ``_ex_``.\n\n## Contributing\n\nThis is mostly an experiment with advanced macro features and the ``setjmp``/``longjmp``.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F5cover%2Fc-exceptions","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F5cover%2Fc-exceptions","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F5cover%2Fc-exceptions/lists"}