Skip to content

Commit 90f9748

Browse files
committed
Feature.enabled should not raise Not_found
Checking unregistered features triggered Not_found. CIL checks for "epicenter" by default, in particular.
1 parent da06971 commit 90f9748

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

src/feature.ml

+6-2
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,13 @@ let registered s =
6464
try ignore(find s); true
6565
with Not_found -> false
6666

67-
let enabled s = (find s).fd_enabled
67+
let enabled s = try (find s).fd_enabled with Not_found -> false
6868

69-
let enable s = let f = find s in f.fd_enabled <- true
69+
let enable s =
70+
try
71+
let f = find s in f.fd_enabled <- true
72+
with Not_found ->
73+
E.s (E.error "cannot enable feature %s: not found" s)
7074

7175
(** Dynamic linking *)
7276

src/feature.mli

+2-2
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,11 @@ val registered : string -> bool
7272
(** Find a feature by name. Raise Not_found if the feature is not registered. *)
7373
val find : string -> t
7474

75-
(** Enable a given feature, by name. Raise Not_found if the feature is not
75+
(** Enable a given feature, by name. Raise {!Errormsg.Error} if the feature is not
7676
* registered. *)
7777
val enable : string -> unit
7878

79-
(** Check if a given feature is enabled. Raise Not_found if the feature is not
79+
(** Check if a given feature is enabled. Return false if the feature is not
8080
* registered. *)
8181
val enabled : string -> bool
8282

0 commit comments

Comments
 (0)