f# - more descriptive IndexOutOfRangeException -


is there way more descriptive index-out-of-range-exceptions ? thought overriding item property this, not work:

type ``[]``<'t>      override arr.item                 get(i) =              if i<0 || >= arr.length                  failwithf "index %d out of range on array(%d): %a" arr.length arr             else                  arr.[i]                 , set (i: int) (value:'t) =              arr.[i] <- value 

if debugging can configure vs break on clr exceptions (debug > exceptions...) see invalid index. otherwise, this:

let idx = -1 try     arr.[idx] <- x :? system.indexoutofrangeexception ->     failwithf "index out of range: %d" idx 

another option shadow array.get/array.set:

module array =     let (arr: 't[]) =         if i<0 || >= arr.length              failwithf "index %d out of range on array(%d): %a" arr.length arr         else              arr.[i]         

Comments

Popular posts from this blog

opencv - DataType<cv::detail::deriv_type>::depth what is it used for -

Why can rails not find a route created by a helper? -

javascript - jquery or ashx not working -