@@ -16,7 +16,7 @@ private Type(int type) {
16
16
this .type = type ;
17
17
}
18
18
19
- public static Type fromInt (int type ) throws Exception {
19
+ public static Type fromInt (int type ) throws IllegalArgumentException {
20
20
switch (type ) {
21
21
case 0 :
22
22
return Type .Float ;
@@ -31,7 +31,7 @@ public static Type fromInt(int type) throws Exception {
31
31
case 5 :
32
32
return Type .Int ;
33
33
default :
34
- throw new Exception ("Unknown type." );
34
+ throw new IllegalArgumentException ("Unknown type." );
35
35
}
36
36
}
37
37
@@ -96,7 +96,7 @@ public Array(int[] dims, int type) throws Exception {
96
96
set (createEmptyArray (adims , type ));
97
97
}
98
98
99
- public Array (int [] dims , float [] elems ) throws Exception {
99
+ public Array (int [] dims , float [] elems ) throws IllegalArgumentException {
100
100
int [] adims = Array .dim4 (dims );
101
101
102
102
int total_size = 1 ;
@@ -105,17 +105,17 @@ public Array(int[] dims, float[] elems) throws Exception {
105
105
}
106
106
107
107
if (elems == null ) {
108
- throw new Exception ("Null elems object provided" );
108
+ throw new IllegalArgumentException ("Null elems object provided" );
109
109
}
110
110
111
111
if (elems .length > total_size || elems .length < total_size ) {
112
- throw new Exception ("Mismatching dims and array size" );
112
+ throw new IllegalArgumentException ("Mismatching dims and array size" );
113
113
}
114
114
115
115
set (createArrayFromFloat (adims , elems ));
116
116
}
117
117
118
- public Array (int [] dims , double [] elems ) throws Exception {
118
+ public Array (int [] dims , double [] elems ) throws IllegalArgumentException {
119
119
int [] adims = Array .dim4 (dims );
120
120
121
121
int total_size = 1 ;
@@ -124,29 +124,29 @@ public Array(int[] dims, double[] elems) throws Exception {
124
124
}
125
125
126
126
if (elems == null ) {
127
- throw new Exception ("Null elems object provided" );
127
+ throw new IllegalArgumentException ("Null elems object provided" );
128
128
}
129
129
130
130
if (elems .length > total_size || elems .length < total_size ) {
131
- throw new Exception ("Mismatching dims and array size" );
131
+ throw new IllegalArgumentException ("Mismatching dims and array size" );
132
132
}
133
133
134
134
set (createArrayFromDouble (adims , elems ));
135
135
}
136
136
137
- public Array (int [] dims , int [] elems ) throws Exception {
137
+ public Array (int [] dims , int [] elems ) throws IllegalArgumentException {
138
138
int [] adims = Array .dim4 (dims );
139
139
140
140
int total_size = 1 ;
141
141
for (int dim : adims ) {
142
142
total_size *= dim ;
143
143
}
144
144
if (elems == null ) {
145
- throw new Exception ("Null elems object provided" );
145
+ throw new IllegalArgumentException ("Null elems object provided" );
146
146
}
147
147
148
148
if (elems .length > total_size || elems .length < total_size ) {
149
- throw new Exception ("Mismatching dims and array size" );
149
+ throw new IllegalArgumentException ("Mismatching dims and array size" );
150
150
}
151
151
152
152
set (createArrayFromInt (adims , elems ));
@@ -171,7 +171,7 @@ public Array(int[] dims, FloatComplex[] elems) throws Exception {
171
171
set (createArrayFromFloatComplex (adims , elems ));
172
172
}
173
173
174
- public Array (int [] dims , DoubleComplex [] elems ) throws Exception {
174
+ public Array (int [] dims , DoubleComplex [] elems ) throws IllegalArgumentException {
175
175
int [] adims = Array .dim4 (dims );
176
176
177
177
int total_size = 1 ;
@@ -180,11 +180,11 @@ public Array(int[] dims, DoubleComplex[] elems) throws Exception {
180
180
}
181
181
182
182
if (elems == null ) {
183
- throw new Exception ("Null elems object provided" );
183
+ throw new IllegalArgumentException ("Null elems object provided" );
184
184
}
185
185
186
186
if (elems .length > total_size || elems .length < total_size ) {
187
- throw new Exception ("Mismatching dims and array size" );
187
+ throw new IllegalArgumentException ("Mismatching dims and array size" );
188
188
}
189
189
190
190
set (createArrayFromDoubleComplex (adims , elems ));
@@ -204,12 +204,12 @@ public Array.Type type() throws Exception {
204
204
return Array .Type .fromInt (getType (ref ));
205
205
}
206
206
207
- protected static int [] dim4 (int [] dims ) throws Exception {
207
+ protected static int [] dim4 (int [] dims ) throws IllegalArgumentException {
208
208
209
209
if (dims == null ) {
210
- throw new Exception ("Null dimensions object provided" );
210
+ throw new IllegalArgumentException ("Null dimensions object provided" );
211
211
} else if (dims .length > 4 ) {
212
- throw new Exception ("ArrayFire supports up to 4 dimensions only" );
212
+ throw new IllegalArgumentException ("ArrayFire supports up to 4 dimensions only" );
213
213
}
214
214
215
215
int [] adims = new int [] { 1 , 1 , 1 , 1 };
@@ -225,7 +225,7 @@ protected void assertType(Array.Type ty) throws Exception {
225
225
String str = "Type mismatch: " ;
226
226
str = str + "Requested " + ty ;
227
227
str = str + ". Found " + myType ;
228
- throw new Exception (str );
228
+ throw new IllegalArgumentException (str );
229
229
}
230
230
return ;
231
231
}
0 commit comments