Refactor MyMoneyException class

Authored by wojnilowicz on May 10 2018, 12:41 PM.


Refactor MyMoneyException class

MyMoneyException changes in following way:

  1. Untranslated exceptions, as normal user doesn't need to understand

exceptions, only developers do,

  1. Tidied up catching phrase, so it's always catched by const reference,
  2. no d-pointer (there should be no cascade header inclusion) and

reduced implementation to only what() method,

  1. we use code from standard library, which implements what() method, so

we have less to compile,

  1. MyMoneyException constructor is inlined, but it should be short,

because of the use of POD types only,

  1. two defines to throw an exception (explanation below).

mymoneyexception.h contains header for std::runtime_error and two
defines for customizing exception messages.
First define, MYMONEYEXCEPTION constructs the message roughly in the
following way:

  1. construct QString from LINE, which is int,
  2. construct QString from FILE, which is const char *,
  3. take exception message, only QStrings allowed,
  4. construct QString from the three strings above,
  5. construct const char * from QString, for which std::runtime_error has

a constructor.

As one can see, there is lot of effort to throw an exception, so there
MYMONEYEXCEPTION_CSTRING has been introduced, to avoid all above
mentioned memory allocations.

Differential Revision:


wojnilowiczMay 19 2018, 5:48 AM
Differential Revision
D12808: Refactor MyMoneyException class
R261:fc35ce3d7df5: Format CSV plugin headers according to the KDE guidelines