Implemented remaining error response calls

This commit is contained in:
Colin Adams
2013-08-08 10:39:46 +01:00
parent eade6d584c
commit 4c901c3130
4 changed files with 37 additions and 7 deletions

View File

@@ -47,8 +47,7 @@ feature {NONE} -- Implementation
res.put_header_text (a_header.string) res.put_header_text (a_header.string)
end end
else else
-- TODO - req.error_handler.has_error = True write_error_response (req, res)
--handle_internal_server_error (a_handler.last_error (req), req, res)
end end
end end

View File

@@ -248,8 +248,7 @@ feature {NONE} -- Implementation
l_chunk := a_handler.next_chunk (req, a_media_type, a_language_type, a_character_type, a_compression_type) l_chunk := a_handler.next_chunk (req, a_media_type, a_language_type, a_character_type, a_compression_type)
res.put_chunk (l_chunk.a_chunk, l_chunk.a_extension) res.put_chunk (l_chunk.a_chunk, l_chunk.a_extension)
else else
-- TODO - req.error_handler.has_error = True write_error_response (req, res)
-- handle_internal_server_error (a_handler.last_error (req), req, res)
end end
until until
a_handler.finished (req) or not a_handler.response_ok (req) a_handler.finished (req) or not a_handler.response_ok (req)
@@ -259,8 +258,7 @@ feature {NONE} -- Implementation
l_chunk := a_handler.next_chunk (req, a_media_type, a_language_type, a_character_type, a_compression_type) l_chunk := a_handler.next_chunk (req, a_media_type, a_language_type, a_character_type, a_compression_type)
res.put_chunk (l_chunk.a_chunk, l_chunk.a_extension) res.put_chunk (l_chunk.a_chunk, l_chunk.a_extension)
else else
-- TODO - req.error_handler.has_error = True write_error_response (req, res)
-- handle_internal_server_error (a_handler.last_error (req), req, res)
end end
end end
if a_handler.finished (req) then if a_handler.finished (req) then
@@ -334,7 +332,29 @@ feature {NONE} -- Implementation
end end
end end
feature -- Basic operations feature -- Errors
feature -- Error reporting
write_error_response (req: WSF_REQUEST; res: WSF_RESPONSE)
-- Write an error response to `res' using `req.error_handler'.
require
req_attached: req /= Void
res_attached: res /= Void
req_has_error: req.has_error
local
h: HTTP_HEADER
m: READABLE_STRING_8
do
m := req.error_handler.as_string_representation
create h.make
h.put_content_type_text_plain
h.put_content_length (m.count)
res.set_status_code (req.error_handler.primary_error_code)
res.put_header_lines (h)
res.put_string (m)
end
handle_redirection_error (req: WSF_REQUEST; res: WSF_RESPONSE; a_locations: LIST [URI]; a_status_code: INTEGER) handle_redirection_error (req: WSF_REQUEST; res: WSF_RESPONSE; a_locations: LIST [URI]; a_status_code: INTEGER)
-- Write `a_status_code' error to `res'. -- Write `a_status_code' error to `res'.

View File

@@ -464,6 +464,7 @@ feature {NONE} -- Implementation
h.put_content_length (m.count) h.put_content_length (m.count)
h.put_current_date h.put_current_date
res.set_status_code ({HTTP_STATUS_CODE}.internal_server_error) res.set_status_code ({HTTP_STATUS_CODE}.internal_server_error)
res.put_header_lines (h)
res.put_string (m) res.put_string (m)
ensure ensure
response_status_is_set: res.status_is_set response_status_is_set: res.status_is_set

View File

@@ -25,6 +25,16 @@ feature {NONE} -- Initialization
create error_added_actions create error_added_actions
end end
feature -- Access
primary_error_code: INTEGER
-- Code of first error in `errors'
require
at_least_one_error: has_error
do
Result := errors.first.code
end
feature -- Status feature -- Status
has_error: BOOLEAN has_error: BOOLEAN