Skip to content

Commit f316aaf

Browse files
committed
remove sub-modules
1 parent ad03448 commit f316aaf

File tree

6 files changed

+29
-77
lines changed

6 files changed

+29
-77
lines changed

Diff for: src/Core__Error.mjs

-18
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,11 @@
11
// Generated by ReScript, PLEASE EDIT WITH CARE
22

33

4-
var $$EvalError = {};
5-
6-
var $$RangeError = {};
7-
8-
var $$ReferenceError = {};
9-
10-
var $$SyntaxError = {};
11-
12-
var $$TypeError = {};
13-
14-
var $$URIError = {};
15-
164
function panic(msg) {
175
throw new Error("Panic! " + msg + "");
186
}
197

208
export {
21-
$$EvalError ,
22-
$$RangeError ,
23-
$$ReferenceError ,
24-
$$SyntaxError ,
25-
$$TypeError ,
26-
$$URIError ,
279
panic ,
2810
}
2911
/* No side effect */

Diff for: src/Core__Error.res

+6-24
Original file line numberDiff line numberDiff line change
@@ -9,30 +9,12 @@ external toException: t => exn = "%identity"
99
@get external fileName: t => option<string> = "fileName"
1010

1111
@new external make: string => t = "Error"
12-
13-
module EvalError = {
14-
@new external make: string => t = "EvalError"
15-
}
16-
17-
module RangeError = {
18-
@new external make: string => t = "RangeError"
19-
}
20-
21-
module ReferenceError = {
22-
@new external make: string => t = "ReferenceError"
23-
}
24-
25-
module SyntaxError = {
26-
@new external make: string => t = "SyntaxError"
27-
}
28-
29-
module TypeError = {
30-
@new external make: string => t = "TypeError"
31-
}
32-
33-
module URIError = {
34-
@new external make: string => t = "URIError"
35-
}
12+
@new external makeEvalError: string => t = "EvalError"
13+
@new external makeRangeError: string => t = "RangeError"
14+
@new external makeReferenceError: string => t = "ReferenceError"
15+
@new external makeSyntaxError: string => t = "SyntaxError"
16+
@new external makeTypeError: string => t = "TypeError"
17+
@new external makeURIError: string => t = "URIError"
3618

3719
external raise: t => 'a = "%raise"
3820

Diff for: src/Core__Error.resi

+19-31
Original file line numberDiff line numberDiff line change
@@ -85,63 +85,51 @@ Console.log(error->Error.name) // Logs "Error" to the console, because this is a
8585
@new
8686
external make: string => t = "Error"
8787

88-
module EvalError: {
89-
/**
88+
/**
9089
Creates a new `EvalError` with the provided `message`.
9190

9291
See [`EvalError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/EvalError) on MDN.
9392
*/
94-
@new
95-
external make: string => t = "EvalError"
96-
}
97-
module RangeError: {
98-
/**
93+
@new
94+
external makeEvalError: string => t = "EvalError"
95+
/**
9996
Creates a new `RangeError` with the provided `message`.
10097

10198
See [`RangeError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RangeError) on MDN.
10299
*/
103-
@new
104-
external make: string => t = "RangeError"
105-
}
106-
module ReferenceError: {
107-
/**
100+
@new
101+
external makeRangeError: string => t = "RangeError"
102+
/**
108103
Creates a new `ReferenceError` with the provided `message`.
109104

110105
See [`ReferenceError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ReferenceError) on MDN.
111106
*/
112-
@new
113-
external make: string => t = "ReferenceError"
114-
}
115-
module SyntaxError: {
116-
/**
107+
@new
108+
external makeReferenceError: string => t = "ReferenceError"
109+
/**
117110
Creates a new `SyntaxError` with the provided `message`.
118111

119112
See [`SyntaxError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SyntaxError) on MDN.
120113
*/
121-
@new
122-
external make: string => t = "SyntaxError"
123-
}
124-
module TypeError: {
125-
/**
114+
@new
115+
external makeSyntaxError: string => t = "SyntaxError"
116+
/**
126117
Creates a new `TypeError` with the provided `message`.
127118

128119
See [`TypeError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypeError) on MDN.
129120
*/
130-
@new
131-
external make: string => t = "TypeError"
132-
}
133-
module URIError: {
134-
/**
121+
@new
122+
external makeTypeError: string => t = "TypeError"
123+
/**
135124
Creates a new `URIError` with the provided `message`.
136125

137126
See [`URIError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/URIError) on MDN.
138127
*/
139-
@new
140-
external make: string => t = "URIError"
141-
}
128+
@new
129+
external makeURIError: string => t = "URIError"
142130

143131
/**
144-
Raises (throws in JavaScript language) the provided `Error.t`, which will stop execution.
132+
Raises (throws in JavaScript language) the provided `Error.t`, which will stop execution. See [Exceptions in ReScript](https://rescript-lang.org/docs/manual/latest/exception)
145133

146134
## Examples
147135
```rescript

Diff for: src/Core__Int.res

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ let rangeWithOptions = (start, end, options) => {
4848
let step = switch options.step {
4949
| None => isInverted ? -1 : 1
5050
| Some(0) if start !== end =>
51-
Core__Error.raise(Core__Error.RangeError.make("Incorrect range arguments"))
51+
Core__Error.raise(Core__Error.makeRangeError("Incorrect range arguments"))
5252
| Some(n) => n
5353
}
5454

Diff for: test/IntTests.res

+2-2
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ Test.run(
4545
__POS_OF__("rangeWithOptions - positive, increasing, step 0"),
4646
catch(() => Int.rangeWithOptions(3, 6, {step: 0})),
4747
eq,
48-
Error.RangeError.make("Incorrect range arguments"),
48+
Error.makeRangeError("Incorrect range arguments"),
4949
)
5050
Test.run(
5151
__POS_OF__("rangeWithOptions - start == end, step 0"),
@@ -117,7 +117,7 @@ Test.run(
117117
__POS_OF__("rangeWithOptions - positive, increasing, step 0, inclusive"),
118118
catch(() => Int.rangeWithOptions(3, 6, {step: 0, inclusive: true})),
119119
eq,
120-
Error.RangeError.make("Incorrect range arguments"),
120+
Error.makeRangeError("Incorrect range arguments"),
121121
)
122122
Test.run(
123123
__POS_OF__("rangeWithOptions - start == end, step 0, inclusive"),

Diff for: test/TempTests.res

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Console.info("Error")
2727
Console.info("---")
2828
let f = () => {
2929
let error = Error.make("hello")
30-
let typeError = Error.TypeError.make("error")
30+
let typeError = Error.makeTypeError("error")
3131
let g = () => Error.raise(error)
3232
let h = () => Error.raise(typeError)
3333
(g, h)

0 commit comments

Comments
 (0)