Se rendre au contenu
CTech Digital
  • Accueil
  • Services Odoo
  • Services d'IA
  • Contactez-nous
  • 0
  • Nederlands (BE) English (UK) Français
CTech Digital
  • 0
    • Accueil
    • Services Odoo
    • Services d'IA
    • Contactez-nous
  • Nederlands (BE) English (UK) Français

9/6/25

  • Tous les blogs
  • Daily blog
  • 9/6/25
  • 9 juin 2025 par
    CTech Metrology, Luc Wens

    Improving assertion handling

    The information you get for a THROW_ASSERT is "assertion failed" with no further stack information and with a file and line reference to the place where the exception was caught. Also the log is not revealing additional information.

    No need to type here that this is not very useful.

    Required improvements:

    • Add the text of the assertion
    • Make sure that the stack information is used:
      • Show in debug mode in the console
      • Add complete stack in ndjson log files

    Also THROW_ASSERT actually throws an exception in debug mode, but does not in release mode, which does not make alot of sense, because what is the difference then with THROW_ERROR, except that it will do nothing in release mode.

    So what do we expect from an assertion:

    • In debug mode we should see something appear in the console screen
    • We want to find it back in our logs
    • It should contain the stack trace
    • It should not interrupt the execution

    First we make the names a bit safer, if we remove THROW then we keep ASSERT, which is too general, so too high risk for naming collisions. Also for the THROW macro's we'll add CTRACK_ in front, and do a commit for that.

    Next we can make a new class CAssertionCTrack, or maybe better use a CTrack namespace around it.

    CExceptionCTrack does not export to a log file, CTrackReportError will do that in the catch handler, otherwise we would only log CExceptionCtrack exceptions, and not all the other std::exception's.

    That is why we make a new class for assertions, where we do want direct logging output in the constructor.

    Also made a small modif to not include the source line information when a stacktrace is present.

    And found this: https://www.logviewplus.com/docs/overview.html to view ndjson files. The best thing I have seen so far, should set me back 50€, but seems to be worth it.



    in Daily blog
    8/6/25
    Droits d'auteur © CTech Solutions
    Nederlands (BE) | English (UK) | Français
    Généré par Odoo - Le #1 Open Source eCommerce