diff --git a/src/core/CCVector.ml b/src/core/CCVector.ml index 4f90df11..3bf6ab51 100644 --- a/src/core/CCVector.ml +++ b/src/core/CCVector.ml @@ -129,7 +129,7 @@ let grow_with_ v ~filler:x = ) else ( let n = Array.length v.vec in let size = min (2 * n + 3) Sys.max_array_length in - if size = n then failwith "vec: can't grow any further"; + if size = n then invalid_arg "vec: can't grow any further"; resize_ v size v.vec.(0) ) @@ -139,7 +139,7 @@ let grow_with_ v ~filler:x = behave well *) let ensure_assuming_not_empty_ v ~size = if size > Sys.max_array_length - then failwith "vec.ensure: size too big" + then invalid_arg "vec.ensure: size too big" else ( let n = ref (max 8 (Array.length v.vec)) in while !n < size do n := min Sys.max_array_length (2* !n) done; diff --git a/src/core/CCVector.mli b/src/core/CCVector.mli index 17170a7c..88a9edcb 100644 --- a/src/core/CCVector.mli +++ b/src/core/CCVector.mli @@ -66,12 +66,15 @@ val ensure_with : init:'a -> ('a, rw) t -> int -> unit This does not affect [length v]. @param init if [capacity v = 0], used to enforce the type of the vector (see {!create_with}). + @raise Invalid_arg if the size is not suitable (negative, or too big for OCaml arrays) @since 0.14 *) val ensure : ('a, rw) t -> int -> unit (** Hint to the vector that it should have at least the given capacity. Just a hint, will not be enforced if the vector is empty and [init] - is not provided. *) + is not provided. + @raise Invalid_arg if the size is not suitable (negative, or too big for OCaml arrays) +*) val is_empty : ('a, _) t -> bool (** Is the vector empty? *) @@ -114,7 +117,7 @@ val pop : ('a, rw) t -> 'a option (** Remove last element, or [None]. *) val pop_exn : ('a, rw) t -> 'a -(** Remove last element, or raise a Failure if empty. +(** Remove last element, or raise an exception if empty. @raise Empty on an empty vector. *) val top : ('a, _) t -> 'a option