Permalink
Browse files

Warn user when trying to add a repository that specifies an unsupport…

…ed backend
  • Loading branch information...
1 parent 57256c4 commit 0256cca8a741f760cf0c66da5ac23d1f1c31c0ca Vincent Bernardoff committed Aug 29, 2012
Showing with 12 additions and 3 deletions.
  1. +2 −1 src/client.ml
  2. +8 −2 src/repositories.ml
  3. +2 −0 src/repositories.mli
View
@@ -1733,8 +1733,9 @@ let remote action =
if List.exists (fun r -> Repository.name r = name) repos then
Globals.error_and_exit "%s is already a remote repository" name
else (
+ (try Repositories.init repo with Repositories.Unknown_backend ->
+ Globals.error_and_exit "\"%s\" is not a supported backend" (Repository.kind repo));
log "Adding %s" (Repository.to_string repo);
- Repositories.init repo;
update_config (repo :: repos)
);
update ()
View
@@ -29,13 +29,19 @@ module type BACKEND = sig
val upload_dir: address:address -> dirname -> Filename.Set.t
end
+exception Unknown_backend
+
let backends = Hashtbl.create 8
let find_backend r =
- Hashtbl.find backends (Repository.kind r)
+ try
+ Hashtbl.find backends (Repository.kind r)
+ with Not_found -> raise Unknown_backend
let find_backend_by_kind k =
- Hashtbl.find backends k
+ try
+ Hashtbl.find backends k
+ with Not_found -> raise Unknown_backend
let register_backend name backend =
Hashtbl.replace backends name backend
@@ -20,6 +20,8 @@
open Types
+exception Unknown_backend
+
(** Initialize {i $opam/repo/$repo} *)
val init: repository -> unit

0 comments on commit 0256cca

Please sign in to comment.