mirror of
https://github.com/Relintai/rcpp_framework.git
synced 2024-11-10 00:52:11 +01:00
Reworked error handling.
This commit is contained in:
parent
413e9efbc8
commit
fd106fc785
@ -108,7 +108,7 @@ void Request::send_file(const String &p_file_path) {
|
||||
}
|
||||
|
||||
void Request::send_error(int error_code) {
|
||||
server->get_web_root()->send_error(error_code, this);
|
||||
server->get_web_root()->handle_error_send_request(this, error_code);
|
||||
}
|
||||
|
||||
void Request::reset() {
|
||||
|
@ -2,6 +2,7 @@
|
||||
#include "web_node.h"
|
||||
|
||||
#include "request.h"
|
||||
#include "http_enums.h"
|
||||
|
||||
#include "core/settings/settings.h"
|
||||
|
||||
@ -70,6 +71,14 @@ void WebNode::set_database(Database *db) {
|
||||
void WebNode::handle_request_main(Request *request) {
|
||||
}
|
||||
|
||||
void WebNode::handle_error_send_request(Request *request, const int error_code) {
|
||||
//this is a fallback error handler.
|
||||
//Webroot implements a proper one
|
||||
request->compiled_body = "<html><body>Internal server error!</body></html>";
|
||||
request->set_status_code(HTTP_STATUS_CODE_503_SERVICE_UNAVAILABLE);
|
||||
request->send();
|
||||
}
|
||||
|
||||
void WebNode::create_validators() {
|
||||
}
|
||||
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
#include "core/nodes/node.h"
|
||||
#include "core/reference.h"
|
||||
#include "core/variant.h"
|
||||
|
||||
class Request;
|
||||
class Settings;
|
||||
@ -31,6 +32,8 @@ public:
|
||||
#endif
|
||||
|
||||
virtual void handle_request_main(Request *request);
|
||||
virtual void handle_error_send_request(Request *request, const int error_code);
|
||||
|
||||
virtual void create_validators();
|
||||
|
||||
virtual void create_table();
|
||||
|
@ -93,6 +93,10 @@ void WebRoot::handle_request_main(Request *request) {
|
||||
// normal routing
|
||||
WebRouterNode::handle_request_main(request);
|
||||
}
|
||||
/*
|
||||
void WebRoot::handle_error_send_request(Request *request, const int error_code) {
|
||||
|
||||
}*/
|
||||
|
||||
bool WebRoot::try_send_wwwroot_file(Request *request) {
|
||||
const String &path = request->get_path_full();
|
||||
|
@ -35,6 +35,8 @@ public:
|
||||
static std::string default_generic_error_body;
|
||||
|
||||
void handle_request_main(Request *request);
|
||||
//void handle_error_send_request(Request *request, const int error_code);
|
||||
|
||||
bool try_send_wwwroot_file(Request *request);
|
||||
void send_error(int error_code, Request *request);
|
||||
void send_file(const std::string &path, Request *request);
|
||||
|
Loading…
Reference in New Issue
Block a user