Skip to content

Commit

Permalink
changed custom exception name
Browse files Browse the repository at this point in the history
  • Loading branch information
iamAbhishekkumar committed Oct 7, 2024
1 parent baf7471 commit c3c7193
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 6 deletions.
2 changes: 1 addition & 1 deletion include/gitRepo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class GitRepo {
gitdir = fs::path(worktree) / DOTGIT;

if (!(force || (fs::exists(gitdir) && fs::is_directory(gitdir)))) {
throw Exception("Not a Git repository" + worktree);
throw GitException("Not a Git repository" + worktree);
}
}

Expand Down
4 changes: 2 additions & 2 deletions include/gitexceptions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
#include <iostream>
#include <string>

class Exception : public std::exception {
class GitException : public std::exception {
private:
std::string message;

public:
// Constructor accepts a const char* that is used to set
// the exception message
Exception(const std::string& msg) : message(msg) {}
GitException(const std::string& msg) : message(msg) {}

// Override the what() method to return our message
const char* what() const throw();
Expand Down
4 changes: 1 addition & 3 deletions src/gitexceptions.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#include <../include/gitexceptions.hpp>

Exception::Exception(const std::string& msg) : message(msg) {}

// Override the what() method to return our message
const char* Exception::what() const throw() { return message.c_str(); }
const char* GitException::what() const throw() { return message.c_str(); }

0 comments on commit c3c7193

Please sign in to comment.