GithubHelp home page GithubHelp logo

Exception handling about libosmium HOT 5 CLOSED

osmcode avatar osmcode commented on July 23, 2024
Exception handling

from libosmium.

Comments (5)

springmeyer avatar springmeyer commented on July 23, 2024

My vote: std::runtime_exception all the way unless you need to catch and re throw somewhere specifically inside the library, then a custom exception could be through/caught and re throw for the user as a runtime exception. I think the type of exception is much less important that that all exceptions can be caught as std:exception and that they provide a helpful what().

from libosmium.

joto avatar joto commented on July 23, 2024
  • All exceptions thrown derive from std::exception
  • Where applicable exceptions should be or derive from std::runtime_error
  • All osmium-specific exceptions are directly in namespace osmium
  • Osmium-specific exceptions should be used in cases where targeted catch clauses will probably be used
  • All exceptions need to be documented
  • All functions throwing exceptions need to document which exceptions they throw

from libosmium.

daniel-j-h avatar daniel-j-h commented on July 23, 2024

All functions throwing exceptions need to document which exceptions they throw

Strictly speaking, it would be great to also document exception safety and guarantees we can give and also what we can not guarantee for. For example, where can we provide the strong exception safety guarantee, where is it not possible (or simply not implemented) and what happens in those cases.

This gives a great summary of what this means for the code.

The documentation currently lacks this, making it hard to reason about correctness for simple scenarios like: "what happens if my handler throws", and "what happens if my handler throws and there is a node cache handler in front of it" and "how is the interaction between handlers when one of them throws?" and more. Of course I can read the code and do some tests, but it would be great to document this.

from libosmium.

joto avatar joto commented on July 23, 2024

I agree. But it is a huge task and we have to keep the documentation in sync with the implementation. So more of a long-term project. :-)

from libosmium.

joto avatar joto commented on July 23, 2024

This has mostly been done now. If anybody finds cases where exceptions are not used in the right way, open individual issues for it.

from libosmium.

Related Issues (20)

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.