From bfbbf4082779a7535cac2fb270fd928178ae7e70 Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Sat, 14 Feb 2015 19:10:19 +0100 Subject: Unify exceptions for unknown/invalid endpoints Signed-off-by: Florian Pritz --- application/controllers/api.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'application/controllers') diff --git a/application/controllers/api.php b/application/controllers/api.php index 837f62e89..644a726e7 100644 --- a/application/controllers/api.php +++ b/application/controllers/api.php @@ -32,11 +32,11 @@ class Api extends MY_Controller { $major = intval(explode(".", $requested_version)[0]); if (!preg_match("/^[a-zA-Z-_]+$/", $controller)) { - throw new \exceptions\PublicApiException("api/invalid-controller-value", "Invalid controller requested"); + throw new \exceptions\PublicApiException("api/invalid-endpoint", "Invalid endpoint requested"); } if (!preg_match("/^[a-zA-Z-_]+$/", $function)) { - throw new \exceptions\PublicApiException("api/invalid-function-value", "Invalid function requested"); + throw new \exceptions\PublicApiException("api/invalid-endpoint", "Invalid endpoint requested"); } $namespace = "controllers\\api\\v".$major; @@ -48,12 +48,12 @@ class Api extends MY_Controller { } if (!class_exists($class)) { - throw new \exceptions\PublicApiException("api/unknown-controller", "Unknown controller requested"); + throw new \exceptions\PublicApiException("api/unknown-endpoint", "Unknown endpoint requested"); } $c= new $class; if (!method_exists($c, $function)) { - throw new \exceptions\PublicApiException("api/unknown-function", "Unknown function requested"); + throw new \exceptions\PublicApiException("api/unknown-endpoint", "Unknown endpoint requested"); } return send_json_reply($c->$function()); } catch (\exceptions\PublicApiException $e) { -- cgit v1.2.3-24-g4f1b