lundi 2 décembre 2019

Documenting a function that re-throws an error

I wonder what the correct way of documenting, in doxygen, the following is.

Having a class defining some validators like:

class Validators {
    /**
    * @fn A
    * @brief sees if x is too large.
    * @param[in] x the input to validate
    * @throws runtime_error when otx is too large.
    */
    static void A(int x) {
        if (x > 5) {
            throw std::runtime_error("x too large");
        }
    }
};

Using this valdator in a function like:

#include "validator.h"

class MyClass {
public:
    void setX(int x) {
        Validators::A(x);
    }
};

How should I document that setX() re-throws the runtime_error thrown by A(), or should I not document that at all?

Aucun commentaire:

Enregistrer un commentaire