Design Pattern Examples
Overview of object-oriented design patterns
argumentnull_error.h
Go to the documentation of this file.
1
5
6#pragma once
7#ifndef __ARGUMENTNULL_ERROR_H__
8#define __ARGUMENTNULL_ERROR_H__
9
10#include <stdexcept>
11#include <string>
12
13namespace Helpers
14{
18 class argumentnull_error : public std::runtime_error
19 {
20 private:
21 std::string _parameter;
22 public:
28 argumentnull_error(const std::string &parm, const std::string &what_arg)
29 : runtime_error(what_arg)
30 , _parameter(parm)
31 {
32 }
33
39 argumentnull_error(const char* parm, const char* what_arg)
40 : runtime_error(what_arg)
41 , _parameter(parm != nullptr ? parm : "")
42 {
43 }
44
49 std::string parameter()
50 {
51 return _parameter;
52 }
53 };
54
55} // end namespace
56
57#endif // __ARGUMENTNULL_ERROR_H__
Exception for arguments that are null.
argumentnull_error(const char *parm, const char *what_arg)
Constructor.
std::string parameter()
Retrieve the parameter associated with the exception.
argumentnull_error(const std::string &parm, const std::string &what_arg)
Constructor.
The namespace containing all the "helper" functions in the C++ code.