Skip to content

Commit 4f5313a

Browse files
committed
rename raise to throw in API docs
1 parent 9acd533 commit 4f5313a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+176
-176
lines changed

packages/@rescript/runtime/Belt.res

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ One common confusion comes from the way Belt handles array access. It differs fr
9999
let letters = ["a", "b", "c"]
100100
let a = letters[0] // a == "a"
101101
let capitalA = Js.String.toUpperCase(a)
102-
let k = letters[10] // Raises an exception! The 10th index doesn't exist.
102+
let k = letters[10] // Throws an exception! The 10th index doesn't exist.
103103
```
104104
105105
Because Belt avoids exceptions and returns `options` instead, this code behaves differently:
@@ -114,7 +114,7 @@ let captialA = Js.String.toUpperCase(a) // Type error! This code will not compil
114114
let k = letters[10] // k == None
115115
```
116116
117-
Although we've fixed the problem where `k` raises an exception, we now have a type error when trying to capitalize `a`. There are a few things going on here:
117+
Although we've fixed the problem where `k` throws an exception, we now have a type error when trying to capitalize `a`. There are a few things going on here:
118118
119119
- Reason transforms array index access to the function `Array.get`. So `letters[0]` is the same as `Array.get(letters, 0)`.
120120
- The compiler uses whichever `Array` module is in scope. If you `open Belt`, then it uses `Belt.Array`.

packages/@rescript/runtime/Belt_Array.resi

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,13 @@ Belt.Array.get(["a", "b", "c"], -1) == None
4747
let get: (t<'a>, int) => option<'a>
4848

4949
/**
50-
Raise an exception if `i` is out of range.
50+
Throw an exception if `i` is out of range.
5151
Otherwise return the value at index `i` in `arr`.
5252
*/
5353
let getExn: (t<'a>, int) => 'a
5454

5555
/**
56-
Raise an exception if `i` is out of range.
56+
Throw an exception if `i` is out of range.
5757
Otherwise return the value at index `i` in `arr`.
5858
*/
5959
let getOrThrow: (t<'a>, int) => 'a
@@ -83,12 +83,12 @@ with `x`. Returning `false` means not updated due to out of range.
8383
let set: (t<'a>, int, 'a) => bool
8484

8585
/**
86-
`setExn(arr, i, x)` raise an exception if `i` is out of range.
86+
`setExn(arr, i, x)` throw an exception if `i` is out of range.
8787
*/
8888
let setExn: (t<'a>, int, 'a) => unit
8989

9090
/**
91-
`setOrThrow(arr, i, x)` raise an exception if `i` is out of range.
91+
`setOrThrow(arr, i, x)` throw an exception if `i` is out of range.
9292
*/
9393
let setOrThrow: (t<'a>, int, 'a) => unit
9494

@@ -774,7 +774,7 @@ let eq: (t<'a>, t<'a>, ('a, 'a) => bool) => bool
774774
/**
775775
Unsafe `truncateToLengthUnsafe(xs, n)` sets length of array `xs` to `n`. If `n`
776776
is greater than the length of `xs`; the extra elements are set to `Js.Null_undefined.null`.
777-
If `n` is less than zero; raises a `RangeError`.
777+
If `n` is less than zero; throws a `RangeError`.
778778
779779
## Examples
780780

packages/@rescript/runtime/Belt_List.res

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -494,9 +494,9 @@ let shuffle = xs => {
494494
/* fillAuxMap arr 0 x f; */
495495
/* J.array arr */
496496

497-
/* TODO: best practice about raising excpetion
498-
1. raise OCaml exception, no stacktrace
499-
2. raise JS exception, how to pattern match
497+
/* TODO: best practice about raising exception
498+
1. throw OCaml exception, no stacktrace
499+
2. throw JS exception, how to pattern match
500500
*/
501501

502502
let rec reverseConcat = (l1, l2) =>

packages/@rescript/runtime/Belt_List.resi

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ Belt.List.head(list{1, 2, 3}) == Some(1)
6363
let head: t<'a> => option<'a>
6464

6565
/**
66-
Same as `Belt.List.head` but raises an exception if `someList` is empty. Use
66+
Same as `Belt.List.head` but throws an exception if `someList` is empty. Use
6767
with care.
6868
6969
## Examples
@@ -72,7 +72,7 @@ with care.
7272
Belt.List.headExn(list{1, 2, 3}) == 1
7373
7474
switch Belt.List.headExn(list{}) {
75-
// Raises an Error
75+
// Throws an Error
7676
| exception _ => assert(true)
7777
| _ => assert(false)
7878
}
@@ -81,7 +81,7 @@ switch Belt.List.headExn(list{}) {
8181
let headExn: t<'a> => 'a
8282

8383
/**
84-
Same as `Belt.List.head` but raises an exception if `someList` is empty. Use
84+
Same as `Belt.List.head` but throws an exception if `someList` is empty. Use
8585
with care.
8686
8787
## Examples
@@ -90,7 +90,7 @@ with care.
9090
Belt.List.headOrThrow(list{1, 2, 3}) == 1
9191
9292
switch Belt.List.headOrThrow(list{}) {
93-
// Raises an Error
93+
// Throws an Error
9494
| exception _ => assert(true)
9595
| _ => assert(false)
9696
}
@@ -113,7 +113,7 @@ Belt.List.tail(list{}) == None
113113
let tail: t<'a> => option<t<'a>>
114114

115115
/**
116-
Same as `Belt.List.tail` but raises an exception if `someList` is empty. Use
116+
Same as `Belt.List.tail` but throws an exception if `someList` is empty. Use
117117
with care.
118118
119119
## Examples
@@ -122,7 +122,7 @@ with care.
122122
Belt.List.tailExn(list{1, 2, 3}) == list{2, 3}
123123
124124
switch Belt.List.tailExn(list{}) {
125-
// Raises an Error
125+
// Throws an Error
126126
| exception _ => assert(true)
127127
| _ => assert(false)
128128
}
@@ -131,7 +131,7 @@ switch Belt.List.tailExn(list{}) {
131131
let tailExn: t<'a> => t<'a>
132132

133133
/**
134-
Same as `Belt.List.tail` but raises an exception if `someList` is empty. Use
134+
Same as `Belt.List.tail` but throws an exception if `someList` is empty. Use
135135
with care.
136136
137137
## Examples
@@ -140,7 +140,7 @@ with care.
140140
Belt.List.tailOrThrow(list{1, 2, 3}) == list{2, 3}
141141
142142
switch Belt.List.tailOrThrow(list{}) {
143-
// Raises an Error
143+
// Throws an Error
144144
| exception _ => assert(true)
145145
| _ => assert(false)
146146
}
@@ -178,7 +178,7 @@ abc->Belt.List.get(4) == None
178178
let get: (t<'a>, int) => option<'a>
179179

180180
/**
181-
Same as `Belt.List.get` but raises an exception if `index` is larger than the
181+
Same as `Belt.List.get` but throws an exception if `index` is larger than the
182182
length. Use with care.
183183
184184
## Examples
@@ -189,7 +189,7 @@ let abc = list{"A", "B", "C"}
189189
abc->Belt.List.getExn(1) == "B"
190190
191191
switch abc->Belt.List.getExn(4) {
192-
// Raises an Error
192+
// Throws an Error
193193
| exception _ => assert(true)
194194
| _ => assert(false)
195195
}
@@ -198,7 +198,7 @@ switch abc->Belt.List.getExn(4) {
198198
let getExn: (t<'a>, int) => 'a
199199

200200
/**
201-
Same as `Belt.List.get` but raises an exception if `index` is larger than the
201+
Same as `Belt.List.get` but throws an exception if `index` is larger than the
202202
length. Use with care.
203203
204204
## Examples
@@ -209,7 +209,7 @@ let abc = list{"A", "B", "C"}
209209
abc->Belt.List.getOrThrow(1) == "B"
210210
211211
switch abc->Belt.List.getOrThrow(4) {
212-
// Raises an Error
212+
// Throws an Error
213213
| exception _ => assert(true)
214214
| _ => assert(false)
215215
}

packages/@rescript/runtime/Belt_Map.resi

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ let getWithDefault: (t<'k, 'v, 'id>, 'k, 'v) => 'v
359359
360360
See `Belt.Map.get`
361361
362-
raise when `k` not exist
362+
throw when `k` not exist
363363
*/
364364
let getExn: (t<'k, 'v, 'id>, 'k) => 'v
365365

@@ -368,7 +368,7 @@ let getExn: (t<'k, 'v, 'id>, 'k) => 'v
368368
369369
See `Belt.Map.get`
370370
371-
raise when `k` not exist
371+
throw when `k` not exist
372372
*/
373373
let getOrThrow: (t<'k, 'v, 'id>, 'k) => 'v
374374

@@ -535,6 +535,6 @@ Returns the packed collection.
535535
let packIdData: (~id: id<'k, 'id>, ~data: Belt_MapDict.t<'k, 'v, 'id>) => t<'k, 'v, 'id>
536536

537537
/**
538-
**raise** when invariant is not held
538+
**throw** when invariant is not held
539539
*/
540540
let checkInvariantInternal: t<_> => unit

packages/@rescript/runtime/Belt_MapInt.resi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ let getExn: (t<'v>, key) => 'v
117117
let getOrThrow: (t<'v>, key) => 'v
118118

119119
/**
120-
**raise** when invariant is not held
120+
**throw** when invariant is not held
121121
*/
122122
let checkInvariantInternal: t<_> => unit
123123

packages/@rescript/runtime/Belt_MapString.resi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ let getExn: (t<'v>, key) => 'v
117117
let getOrThrow: (t<'v>, key) => 'v
118118

119119
/**
120-
**raise** when invariant is not held
120+
**throw** when invariant is not held
121121
*/
122122
let checkInvariantInternal: t<_> => unit
123123

packages/@rescript/runtime/Belt_MutableMap.resi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ let getUndefined: (t<'k, 'a, 'id>, 'k) => Js.undefined<'a>
122122
let getWithDefault: (t<'k, 'a, 'id>, 'k, 'a) => 'a
123123
let getExn: (t<'k, 'a, 'id>, 'k) => 'a
124124
let getOrThrow: (t<'k, 'a, 'id>, 'k) => 'a
125-
/** Raise when invariant is not held. */
125+
/** Throw when invariant is not held. */
126126
let checkInvariantInternal: t<_> => unit
127127

128128
/* ************************************************************************** */

packages/@rescript/runtime/Belt_MutableMapInt.resi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ let getExn: (t<'a>, key) => 'a
109109
let getOrThrow: (t<'a>, key) => 'a
110110

111111
/**
112-
**raise** when invariant is not held
112+
**Throw** when invariant is not held
113113
*/
114114
let checkInvariantInternal: t<_> => unit
115115

packages/@rescript/runtime/Belt_MutableMapString.resi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ let getExn: (t<'a>, key) => 'a
109109
let getOrThrow: (t<'a>, key) => 'a
110110

111111
/**
112-
**raise** when invariant is not held
112+
**throw** when invariant is not held
113113
*/
114114
let checkInvariantInternal: t<_> => unit
115115

0 commit comments

Comments
 (0)