Skip to content

Commit 768dec3

Browse files
committed
Remove specific exceptions.
1 parent 2fc8f6f commit 768dec3

File tree

3 files changed

+8
-23
lines changed

3 files changed

+8
-23
lines changed

src/http_utils.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ ip_representation::ip_representation(const std::string& ip)
377377
{
378378
if(y != 12)
379379
{
380-
throw bad_ip_format_exception();
380+
throw std::invalid_argument("IP is badly formatted");
381381
}
382382
if(parts[i].find('.') != std::string::npos)
383383
{
@@ -403,12 +403,12 @@ ip_representation::ip_representation(const std::string& ip)
403403
}
404404
else
405405
{
406-
throw bad_ip_format_exception();
406+
throw std::invalid_argument("IP is badly formatted");
407407
}
408408
}
409409
else
410410
{
411-
throw bad_ip_format_exception();
411+
throw std::invalid_argument("IP is badly formatted");
412412
}
413413
}
414414
}
@@ -434,7 +434,7 @@ ip_representation::ip_representation(const std::string& ip)
434434
}
435435
else
436436
{
437-
throw bad_ip_format_exception();
437+
throw std::invalid_argument("IP is badly formatted");
438438
}
439439
}
440440
}
@@ -459,7 +459,7 @@ ip_representation::ip_representation(const std::string& ip)
459459
}
460460
else
461461
{
462-
throw bad_ip_format_exception();
462+
throw std::invalid_argument("IP is badly formatted");
463463
}
464464
}
465465
}
@@ -497,7 +497,7 @@ char* load_file (const char *filename)
497497
return content;
498498
}
499499
else
500-
throw file_access_exception();
500+
throw std::invalid_argument("Unable to open file");
501501
return content;
502502
}
503503

src/httpserver/http_utils.hpp

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -42,22 +42,6 @@
4242
namespace httpserver {
4343
namespace http {
4444

45-
class bad_ip_format_exception: public std::exception
46-
{
47-
virtual const char* what() const throw()
48-
{
49-
return "IP is badly formatted!";
50-
}
51-
};
52-
53-
class file_access_exception: public std::exception
54-
{
55-
virtual const char* what() const throw()
56-
{
57-
return "Unable to open file!";
58-
}
59-
};
60-
6145
class http_utils
6246
{
6347
public:

src/webserver.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include <sys/stat.h>
2929
#include <sys/types.h>
3030
#include <sys/time.h>
31+
#include <stdexcept>
3132

3233
#if defined(__MINGW32__) || defined(__CYGWIN32__)
3334
#include <winsock2.h>
@@ -904,7 +905,7 @@ int webserver::finalize_answer(
904905
{
905906
mr->dhrs->get_raw_response(&raw_response, this);
906907
}
907-
catch(const file_access_exception& fae)
908+
catch(const std::invalid_argument& iae)
908909
{
909910
mr->dhrs = NEW_OR_MOVE(http_response, not_found_page(mr));
910911
mr->dhrs->get_raw_response(&raw_response, this);

0 commit comments

Comments
 (0)