Skip to content

Commit 5d8b5ea

Browse files
committed
Cleanup
1 parent 5f1199e commit 5d8b5ea

13 files changed

Lines changed: 234 additions & 341 deletions
Lines changed: 34 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,44 @@
11
#pragma once
22
#include "Exception.hpp"
33

4-
namespace shared
4+
namespace shared::exception
55
{
6-
namespace exception
6+
//--------------------------------------------------------------
7+
/// \brief Exception for faulty download
8+
//--------------------------------------------------------------
9+
class CDownloadFailed final : public CException
710
{
8-
//--------------------------------------------------------------
9-
/// \brief Exception for faulty download
10-
//--------------------------------------------------------------
11-
class CDownloadFailed : public CException
11+
public:
12+
explicit CDownloadFailed(const std::string& failToDownload)
13+
: CException(std::string("Fail to download ")
14+
+ failToDownload)
1215
{
13-
public:
16+
}
1417

15-
//--------------------------------------------------------------
16-
/// \brief Constructor
17-
//--------------------------------------------------------------
18-
explicit CDownloadFailed(const std::string& failToDownload)
19-
: CException(std::string("Fail to download ")
20-
+ failToDownload)
21-
{
22-
}
2318

19+
CDownloadFailed(const std::string& failToDownload,
20+
const std::string& reason)
21+
: CException(std::string("Fail to download ")
22+
+ failToDownload + " "
23+
+ reason)
24+
{
25+
}
2426

25-
//--------------------------------------------------------------
26-
/// \brief Constructor
27-
//--------------------------------------------------------------
28-
CDownloadFailed(const std::string& failToDownload,
29-
const std::string& reason)
30-
: CException(std::string("Fail to download ")
31-
+ failToDownload + " "
32-
+ reason)
33-
{
34-
}
35-
36-
//--------------------------------------------------------------
37-
/// \brief Constructor
38-
//--------------------------------------------------------------
39-
CDownloadFailed(const std::string& failToDownload,
40-
const boost::system::error_code& error)
41-
: CException(std::string("Fail to download ")
42-
+ failToDownload
43-
+ " Message : "
44-
+ error.message()
45-
+ " \nCategory : "
46-
+ error.category().name()
47-
+ "\nValue : "
48-
+ std::to_string(error.value()))
49-
{
50-
}
27+
CDownloadFailed(const std::string& failToDownload,
28+
const boost::system::error_code& error)
29+
: CException(std::string("Fail to download ")
30+
+ failToDownload
31+
+ " Message : "
32+
+ error.message()
33+
+ " \nCategory : "
34+
+ error.category().name()
35+
+ "\nValue : "
36+
+ std::to_string(error.value()))
37+
{
38+
}
5139

52-
//--------------------------------------------------------------
53-
/// \brief Destructor
54-
//--------------------------------------------------------------
55-
virtual ~CDownloadFailed() throw()
56-
{
57-
}
58-
};
59-
}
60-
} // namespace shared::exception
40+
~CDownloadFailed() throw() override
41+
{
42+
}
43+
};
44+
}

sources/shared/shared/exception/EmptyResult.hpp

Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,25 @@
22

33
#include "Exception.hpp"
44

5-
namespace shared
5+
namespace shared::exception
66
{
7-
namespace exception
7+
//--------------------------------------------------------------
8+
/// \class CEmptyResult Exception for non implemented part of code
9+
//--------------------------------------------------------------
10+
class CEmptyResult final : public CException
811
{
9-
//--------------------------------------------------------------
10-
/// \class CEmptyResult Exception for non implemented part of code
11-
//--------------------------------------------------------------
12-
class CEmptyResult : public CException
12+
public:
13+
explicit CEmptyResult(const std::string& message)
14+
: CException(message)
1315
{
14-
public:
15-
//--------------------------------------------------------------
16-
/// \brief Constructor
17-
//--------------------------------------------------------------
18-
explicit CEmptyResult(const std::string& message)
19-
: CException(message)
20-
{
21-
}
16+
}
2217

23-
//--------------------------------------------------------------
24-
/// \brief Destructor
25-
//--------------------------------------------------------------
26-
virtual ~CEmptyResult() throw()
27-
{
28-
}
29-
};
30-
}
31-
} // namespace shared::exception
18+
CEmptyResult() = delete;
19+
CEmptyResult(const CEmptyResult&) = default;
20+
CEmptyResult(CEmptyResult&&) = default;
21+
CEmptyResult& operator=(const CEmptyResult&) = default;
22+
CEmptyResult& operator=(CEmptyResult&&) = default;
23+
24+
~CEmptyResult() noexcept override = default;
25+
};
26+
}

sources/shared/shared/exception/Exception.hpp

Lines changed: 30 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -3,43 +3,42 @@
33
#include <string>
44
#include <stdexcept>
55

6-
namespace shared
6+
namespace shared::exception
77
{
8-
namespace exception
8+
//--------------------------------------------------------------
9+
/// \brief Standard exception with some text
10+
//--------------------------------------------------------------
11+
class CException : public std::exception
912
{
13+
public:
14+
CException() = delete;
15+
1016
//--------------------------------------------------------------
11-
/// \brief Standard exception with some text
17+
/// \brief Constructor
18+
/// \param[in] message Exception message
1219
//--------------------------------------------------------------
13-
class CException : public std::exception
20+
explicit CException(const char* message)
21+
: m_message(message)
1422
{
15-
public:
16-
CException() = delete;
17-
18-
//--------------------------------------------------------------
19-
/// \brief Constructor
20-
/// \param[in] message Exception message
21-
//--------------------------------------------------------------
22-
explicit CException(const char* message)
23-
:m_message(message)
24-
{
25-
}
23+
}
2624

27-
explicit CException(const std::string& message)
28-
: m_message(message)
29-
{
30-
}
25+
explicit CException(const std::string& message)
26+
: m_message(message)
27+
{
28+
}
3129

32-
virtual ~CException() noexcept = default;
30+
~CException() noexcept override = default;
3331

34-
//--------------------------------------------------------------
35-
/// \brief Build full message explaining exception reason
32+
//--------------------------------------------------------------
33+
/// \brief Build full message explaining exception reason
3634
/// \return message explaining exception reason
37-
//--------------------------------------------------------------
38-
const char *what() const noexcept override {
39-
return m_message.what();
40-
}
41-
protected:
42-
std::runtime_error m_message;
43-
};
44-
}
45-
} // namespace shared::exception
35+
//--------------------------------------------------------------
36+
const char* what() const noexcept override
37+
{
38+
return m_message.what();
39+
}
40+
41+
protected:
42+
std::runtime_error m_message;
43+
};
44+
}

sources/shared/shared/exception/Extract.hpp

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,21 @@
22

33
#include "Exception.hpp"
44

5-
namespace shared { namespace exception
5+
namespace shared::exception
66
{
7-
87
//--------------------------------------------------------------
9-
/// \class Exception when archive extraction fails
8+
/// \brief Exception when archive extraction fails
109
//--------------------------------------------------------------
1110
class CExtract : public CException
1211
{
1312
public:
14-
//--------------------------------------------------------------
15-
/// \brief Constructor
16-
//--------------------------------------------------------------
1713
explicit CExtract(const std::string& message)
18-
:CException(message)
14+
: CException(message)
1915
{
2016
}
2117

22-
//--------------------------------------------------------------
23-
/// \brief Destructor
24-
//--------------------------------------------------------------
25-
virtual ~CExtract() throw()
18+
~CExtract() throw() override
2619
{
2720
}
2821
};
29-
30-
} } // namespace shared::exception
22+
}

sources/shared/shared/exception/HttpException.hpp

Lines changed: 22 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,37 +2,34 @@
22
#include "Exception.hpp"
33
#include "shared/http/Codes.h"
44

5-
namespace shared
5+
namespace shared::exception
66
{
7-
namespace exception
7+
//--------------------------------------------------------------
8+
/// \brief Exception handling for protocol errors
9+
//--------------------------------------------------------------
10+
class CHttpException : public CException
811
{
12+
public:
913
//--------------------------------------------------------------
10-
/// \brief Exception handling for protocol errors
11-
//--------------------------------------------------------------
12-
class CHttpException : public CException
13-
{
14-
public:
15-
//--------------------------------------------------------------
16-
/// \brief Constructor
14+
/// \brief Constructor
1715
/// \param[in] message Exception message
1816
/// \param[in] httpCode HTTP code
19-
//--------------------------------------------------------------
20-
CHttpException(const std::string& message,
21-
const http::ECodes& httpCode)
22-
: CException(message),
23-
m_httpCode(httpCode)
24-
{
25-
}
17+
//--------------------------------------------------------------
18+
CHttpException(const std::string& message,
19+
const http::ECodes& httpCode)
20+
: CException(message),
21+
m_httpCode(httpCode)
22+
{
23+
}
2624

27-
const http::ECodes& code() const
28-
{
29-
return m_httpCode;
30-
}
25+
const http::ECodes& code() const
26+
{
27+
return m_httpCode;
28+
}
3129

32-
virtual ~CHttpException() = default;
30+
~CHttpException() override = default;
3331

34-
private:
35-
const http::ECodes m_httpCode;
36-
};
37-
}
32+
private:
33+
const http::ECodes m_httpCode;
34+
};
3835
};
Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,28 @@
11
#pragma once
22
#include "Exception.hpp"
33

4-
namespace shared
4+
namespace shared::exception
55
{
6-
namespace exception
6+
//--------------------------------------------------------------
7+
/// \brief Exception for invalid Hash
8+
//--------------------------------------------------------------
9+
class CInvalidHash : public CException
710
{
8-
//--------------------------------------------------------------
9-
/// \brief Exception for invalid Hash
10-
//--------------------------------------------------------------
11-
class CInvalidHash : public shared::exception::CException
11+
public:
12+
explicit CInvalidHash(const boost::filesystem::path& fileChecked)
13+
: CException(std::string("Invalid MD5 hash for : " + fileChecked.string()))
1214
{
13-
public:
14-
explicit CInvalidHash(const boost::filesystem::path& fileChecked)
15-
: CException(std::string("Invalid MD5 hash for : " + fileChecked.string()))
16-
{
17-
}
15+
}
1816

19-
CInvalidHash(const boost::filesystem::path& fileChecked,
20-
const std::string& expectedHash,
21-
const std::string& computedHash)
22-
: CException(std::string(
23-
"Invalid MD5 hash for : " + fileChecked.string() + " Expected : " + expectedHash + " Computed : " +
24-
computedHash))
25-
{
26-
}
17+
CInvalidHash(const boost::filesystem::path& fileChecked,
18+
const std::string& expectedHash,
19+
const std::string& computedHash)
20+
: CException(std::string(
21+
"Invalid MD5 hash for : " + fileChecked.string() + " Expected : " + expectedHash + " Computed : " +
22+
computedHash))
23+
{
24+
}
2725

28-
virtual ~CInvalidHash() noexcept = default;
29-
};
30-
}
31-
} // namespace shared::exception
26+
~CInvalidHash() noexcept override = default;
27+
};
28+
}

0 commit comments

Comments
 (0)