GithubHelp home page GithubHelp logo

daddinuz / panic Goto Github PK

View Code? Open in Web Editor NEW
3.0 3.0 0.0 49 KB

A panic library to abort execution on non-recoverable errors with a detailed message.

License: MIT License

CMake 24.65% C 74.49% Shell 0.87%
panic error error-handling error-reporting terminate abort c

panic's Introduction

Panic

Build Status

A panic library to abort execution on non-recoverable errors with a detailed message.

#include <stdio.h>
#include <panic.h>

double divide(const double dividend, const double divisor) {
    panic_when(0 == divisor);
    return dividend / divisor;
}

int main() {
    printf("%lf\r\n", divide(8, 0));
    return 0;
}

Output (with PANIC_UNWIND_SUPPORT enabled):

Traceback (most recent call last):
  [0]: (main)
  ->-: (divide) current function

   At: '/panic/examples/main.c:37'
Cause: `0 == divisor`

Optional features

PANIC_UNWIND_SUPPORT

Disabled by default, prints a traceback with function calls useful for debugging.
Enable this feature running cmake -DPANIC_UNWIND_SUPPORT=1 by command line or setting option to ON in sources/build.cmake.

Note: In order to enable this feature libunwind is required.

panic's People

Contributors

daddinuz avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.