MPQC 3.0.0-alpha
Loading...
Searching...
No Matches
exception.hpp
1#ifndef MPQC_UTILITY_EXCEPTION_HPP
2#define MPQC_UTILITY_EXCEPTION_HPP
3
4#include <stdio.h>
5#include <stdarg.h>
6
7#include <string>
8#include <exception>
9#include <iostream>
10#include <sstream>
11
12#include "mpqc/utility/string.hpp"
13
14namespace mpqc {
15
18
20 struct Exception : std::exception {
22 explicit Exception(const std::string &msg = "")
23 : what_(msg) {}
25 explicit Exception(char const *file, long line, const char *fmt = NULL, ...) {
26 what_ = what_ + file + ":" + string_cast(line);
27 if (fmt) {
28 char buffer[1024] = { };
29 va_list args;
30 va_start(args, fmt);
31 vsnprintf(buffer, 1024-1, fmt, args);
32 va_end(args);
33 what_ = what_ + ": " + buffer;
34 }
35 }
36 ~Exception() noexcept {}
37 const char* what() const noexcept {
38 return what_.c_str();
39 }
40 private:
41 std::string what_;
42 };
43
45
46}
47
51#define MPQC_EXCEPTION(...) mpqc::Exception(__FILE__, __LINE__, __VA_ARGS__)
52
53#endif /* MPQC_UTILITY_EXCEPTION_HPP */
std::string string_cast(const T &value)
cast type T to string
Definition string.hpp:14
Contains new MPQC code since version 3.
Definition integralenginepool.hpp:37
MPQC exception class.
Definition exception.hpp:20
Exception(char const *file, long line, const char *fmt=NULL,...)
Constructs exception with an optional printf-style format and arguments.
Definition exception.hpp:25
Exception(const std::string &msg="")
Constructs exception.
Definition exception.hpp:22

Generated at Wed Sep 25 2024 02:45:30 for MPQC 3.0.0-alpha using the documentation package Doxygen 1.12.0.