Skip to content

Commit c7b27a8

Browse files
committed
- adds exception in reflection methods to facilitate detection of issues
1 parent 9bfbcbd commit c7b27a8

5 files changed

Lines changed: 11 additions & 7 deletions

File tree

‎src/main/java/com/microsoft/graph/http/BaseCollectionRequest.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ public T3 buildFromResponse(@Nonnull final T2 response) {
126126
final T3 page = (T3)this.collectionPageClass.getConstructor(response.getClass(), builder.getClass()).newInstance(response, response.nextLink() == null ? null : builder);
127127
return page;
128128
} catch(IllegalArgumentException | InstantiationException | IllegalAccessException | InvocationTargetException | NoSuchMethodException | SecurityException ex) {
129-
return null;
129+
throw new ClientException("Could not find the required class", ex);
130130
}
131131
}
132132

‎src/main/java/com/microsoft/graph/http/BaseCollectionRequestBuilder.java‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.microsoft.graph.http;
22

3+
import com.microsoft.graph.core.ClientException;
34
import com.microsoft.graph.core.IBaseClient;
45

56
import java.lang.reflect.InvocationTargetException;
@@ -61,7 +62,7 @@ public T5 buildRequest(@Nullable final java.util.List<? extends com.microsoft.gr
6162
return collRequestClass.getConstructor(String.class, IBaseClient.class, java.util.List.class)
6263
.newInstance(getRequestUrl(), getClient(), requestOptions);
6364
} catch (IllegalArgumentException | InstantiationException | IllegalAccessException | InvocationTargetException | NoSuchMethodException | SecurityException ex) {
64-
return null;
65+
throw new ClientException("Could not find the required class", ex);
6566
}
6667
}
6768

@@ -77,7 +78,7 @@ public T2 byId(@Nonnull final String id) {
7778
return reqBuilderClass.getConstructor(String.class, IBaseClient.class, java.util.List.class)
7879
.newInstance(getRequestUrlWithAdditionalSegment(id), getClient(), getOptions());
7980
} catch (IllegalArgumentException | InstantiationException | IllegalAccessException | InvocationTargetException | NoSuchMethodException | SecurityException ex) {
80-
return null;
81+
throw new ClientException("Could not find the required class", ex);
8182
}
8283
}
8384
}

‎src/main/java/com/microsoft/graph/http/BaseCollectionWithReferencesRequestBuilder.java‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
package com.microsoft.graph.http;
2424

25+
import com.microsoft.graph.core.ClientException;
2526
import com.microsoft.graph.core.IBaseClient;
2627

2728
import java.lang.reflect.InvocationTargetException;
@@ -70,7 +71,7 @@ public T8 references() {
7071
.getConstructor(String.class, IBaseClient.class, java.util.List.class)
7172
.newInstance(getRequestUrl() + "/$ref", getClient(), getOptions());
7273
} catch(IllegalArgumentException | InstantiationException | IllegalAccessException | InvocationTargetException | NoSuchMethodException | SecurityException ex) {
73-
return null;
74+
throw new ClientException("Could not find the required class", ex);
7475
}
7576
}
7677
}

‎src/main/java/com/microsoft/graph/http/BaseReferenceRequestBuilder.java‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
package com.microsoft.graph.http;
2424

25+
import com.microsoft.graph.core.ClientException;
2526
import com.microsoft.graph.core.IBaseClient;
2627

2728
import java.lang.reflect.InvocationTargetException;
@@ -72,7 +73,7 @@ public T2 buildRequest(@Nullable final java.util.List<? extends com.microsoft.gr
7273
return refRequestClass.getConstructor(String.class, IBaseClient.class, java.util.List.class)
7374
.newInstance(getRequestUrl(), getClient(), requestOptions);
7475
} catch (IllegalArgumentException | InstantiationException | IllegalAccessException | InvocationTargetException | NoSuchMethodException | SecurityException ex) {
75-
return null;
76+
throw new ClientException("Could not find the required class", ex);
7677
}
7778
}
7879
}

‎src/main/java/com/microsoft/graph/http/BaseWithReferenceRequestBuilder.java‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
package com.microsoft.graph.http;
2424

25+
import com.microsoft.graph.core.ClientException;
2526
import com.microsoft.graph.core.IBaseClient;
2627

2728
import java.lang.reflect.InvocationTargetException;
@@ -78,7 +79,7 @@ public T2 buildRequest(@Nullable final java.util.List<? extends com.microsoft.gr
7879
return wReferenceRequestClass.getConstructor(String.class, IBaseClient.class, java.util.List.class)
7980
.newInstance(getRequestUrl(), getClient(), requestOptions);
8081
} catch (IllegalArgumentException | InstantiationException | IllegalAccessException | InvocationTargetException | NoSuchMethodException | SecurityException ex) {
81-
return null;
82+
throw new ClientException("Could not find the required class", ex);
8283
}
8384
}
8485

@@ -93,7 +94,7 @@ public T3 reference(){
9394
return refRequestBuilderClass.getConstructor(String.class, IBaseClient.class, java.util.List.class)
9495
.newInstance(getRequestUrl() + "/$ref", getClient(), getOptions());
9596
} catch (IllegalArgumentException | InstantiationException | IllegalAccessException | InvocationTargetException | NoSuchMethodException | SecurityException ex) {
96-
return null;
97+
throw new ClientException("Could not find the required class", ex);
9798
}
9899
}
99100
}

0 commit comments

Comments
 (0)