diff options
| author | Charles Cabergs <me@cacharle.xyz> | 2020-11-17 19:02:35 +0100 |
|---|---|---|
| committer | Charles Cabergs <me@cacharle.xyz> | 2020-11-17 19:02:35 +0100 |
| commit | 452e6bfa7bb4bca75dc4659bf9d707101b411977 (patch) | |
| tree | f4ee27a96437d6d17a89bbbbc135ae45f9f3faae /cpp05/ex02/Form.cpp | |
| parent | a92013c92bfcd50b0e2561280c9eaa604843ade0 (diff) | |
| download | piscine_cpp-452e6bfa7bb4bca75dc4659bf9d707101b411977.tar.gz piscine_cpp-452e6bfa7bb4bca75dc4659bf9d707101b411977.tar.bz2 piscine_cpp-452e6bfa7bb4bca75dc4659bf9d707101b411977.zip | |
Added cpp05/ex02 main, Added cpp05/ex03
Diffstat (limited to 'cpp05/ex02/Form.cpp')
| -rw-r--r-- | cpp05/ex02/Form.cpp | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/cpp05/ex02/Form.cpp b/cpp05/ex02/Form.cpp index 8f3afc0..9208f7f 100644 --- a/cpp05/ex02/Form.cpp +++ b/cpp05/ex02/Form.cpp @@ -6,7 +6,7 @@ /* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/04/14 19:26:39 by charles #+# #+# */ -/* Updated: 2020/11/17 13:35:10 by cacharle ### ########.fr */ +/* Updated: 2020/11/17 17:09:53 by charles ### ########.fr */ /* */ /* ************************************************************************** */ @@ -53,7 +53,9 @@ void Form::beSigned(Bureaucrat const& b) void Form::execute(Bureaucrat const& executor) const { - if (executor.getGrade() <= m_gradeExecute && m_signed) + if (!m_signed) + throw Form::NoSignatureException(); + if (executor.getGrade() <= m_gradeExecute) executeUnsafe(); else throw Form::GradeTooLowException(); @@ -126,3 +128,23 @@ Form::GradeTooLowException::operator=(GradeTooLowException const& other) Form::GradeTooLowException::~GradeTooLowException() throw() {} char const* Form::GradeTooLowException::what() const throw() { return "Grade is too low for form"; } + +/////////////////////////////////////////////////////////////////////////////// +// Exception signature +/////////////////////////////////////////////////////////////////////////////// + +Form::NoSignatureException::NoSignatureException() : std::exception() {} + +Form::NoSignatureException::NoSignatureException(NoSignatureException const& other) + : std::exception(other) {} + +Form::NoSignatureException& +Form::NoSignatureException::operator=(NoSignatureException const& other) +{ + std::exception::operator=(other); + return *this; +} + +Form::NoSignatureException::~NoSignatureException() throw() {} + +char const* Form::NoSignatureException::what() const throw() { return "No signature"; } |
