From af9dee32ed84a302d3ac0ba3005f9ecc0da7f46e Mon Sep 17 00:00:00 2001 From: Stefano Zacchiroli Date: Wed, 16 Apr 2003 15:41:30 +0000 Subject: [PATCH] bugfix: print a better exception than "Not_found" when "baseuri" parameter for "ls" method is empty or simply unparsable --- helm/http_getter/http_getter.ml | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/helm/http_getter/http_getter.ml b/helm/http_getter/http_getter.ml index 501b9d839..0792d30b5 100644 --- a/helm/http_getter/http_getter.ml +++ b/helm/http_getter/http_getter.ml @@ -71,16 +71,21 @@ let parse_output_format (req: Http_types.request) = let parse_ls_uri = let parse_ls_RE = Pcre.regexp "^(\\w+):(.*)$" in let trailing_slash_RE = Pcre.regexp "/+$" in + let wrong_uri uri = + raise (Http_getter_bad_request ("Invalid /ls baseuri: " ^ uri)) + in fun (req: Http_types.request) -> let baseuri = req#param "baseuri" in - let subs = - Pcre.extract ~rex:parse_ls_RE - (Pcre.replace ~rex:trailing_slash_RE baseuri) - in - match (subs.(1), subs.(2)) with - | "cic", uri -> Cic uri - | "theory", uri -> Theory uri - | _ -> raise (Http_getter_bad_request ("Invalid /ls baseuri: " ^ baseuri)) + try + let subs = + Pcre.extract ~rex:parse_ls_RE + (Pcre.replace ~rex:trailing_slash_RE baseuri) + in + (match (subs.(1), subs.(2)) with + | "cic", uri -> Cic uri + | "theory", uri -> Theory uri + | _ -> wrong_uri baseuri) + with Not_found -> wrong_uri baseuri ;; (* global maps, shared by all threads *) -- 2.39.2