From d59962443687127ea1defc2f8ac41af1c2c02fe4 Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Sat, 25 Oct 2014 13:55:08 +0200 Subject: first go at reworking; needs to be redesigned Signed-off-by: Florian Pritz --- application/helpers/filebin_helper.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'application/helpers/filebin_helper.php') diff --git a/application/helpers/filebin_helper.php b/application/helpers/filebin_helper.php index e5637ce94..465f865f6 100644 --- a/application/helpers/filebin_helper.php +++ b/application/helpers/filebin_helper.php @@ -235,6 +235,22 @@ function send_json_reply($array, $status = "success") $CI->output->set_output(json_encode($reply)); } +function send_json_error_reply($message, $array = null) +{ + $reply = array(); + $reply["status"] = "error"; + $reply["message"] = $message; + + if ($array !== null) { + $reply["data"] = $array; + } + + $CI =& get_instance(); + $CI->output->set_status_header(400); + $CI->output->set_content_type('application/json'); + $CI->output->set_output(json_encode($reply)); +} + function static_storage($key, $value = null) { static $storage = array(); -- cgit v1.2.3-24-g4f1b From 434143c2b01c203bf9030669a14055872121b2c0 Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Sun, 11 Jan 2015 01:39:22 +0100 Subject: improve api errors Signed-off-by: Florian Pritz --- application/helpers/filebin_helper.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'application/helpers/filebin_helper.php') diff --git a/application/helpers/filebin_helper.php b/application/helpers/filebin_helper.php index 465f865f6..a1b540b1d 100644 --- a/application/helpers/filebin_helper.php +++ b/application/helpers/filebin_helper.php @@ -235,10 +235,11 @@ function send_json_reply($array, $status = "success") $CI->output->set_output(json_encode($reply)); } -function send_json_error_reply($message, $array = null) +function send_json_error_reply($error_id, $message, $array = null, $status_code = 400) { $reply = array(); $reply["status"] = "error"; + $reply["error_id"] = $error_id; $reply["message"] = $message; if ($array !== null) { @@ -246,7 +247,7 @@ function send_json_error_reply($message, $array = null) } $CI =& get_instance(); - $CI->output->set_status_header(400); + $CI->output->set_status_header($status_code); $CI->output->set_content_type('application/json'); $CI->output->set_output(json_encode($reply)); } -- cgit v1.2.3-24-g4f1b