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