Skip to content

Commit 6784850

Browse files
committed
added better error handling
1 parent ab5dd32 commit 6784850

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

dts-generator/src/main/java/com/telerik/dts/DtsApi.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,12 @@ private int openPackage(JavaClass prevClass, JavaClass currClass) {
190190
//method related
191191
private void processMethod(Method m, JavaClass clazz) {
192192

193-
loadBaseMethods(clazz); //loaded in "baseMethodNames" and "baseMethods"
193+
try {
194+
loadBaseMethods(clazz); //loaded in "baseMethodNames" and "baseMethods"
195+
}
196+
catch (ClassNotFoundException e) {
197+
e.printStackTrace();
198+
}
194199

195200
String tabs = getTabs(this.indent + 1);
196201

@@ -235,13 +240,16 @@ private void cacheMethodBySignature(Method m) {
235240
}
236241
}
237242

238-
private void loadBaseMethods(JavaClass clazz) {
243+
private void loadBaseMethods(JavaClass clazz) throws ClassNotFoundException {
239244
baseMethodNames = new HashSet<String>();
240245
baseMethods = new ArrayList<Method>();
241246
String scn = clazz.getSuperclassName();
242247
JavaClass currClass = ClassRepo.findClass(scn);
243248
assert currClass != null : "javaClass=" + clazz.getClassName() + " scn=" + scn;
244249

250+
if(currClass == null) {
251+
throw new ClassNotFoundException("Couldn't find class: " + scn + " required by class: " + clazz.getClassName() + ". You need to provide the jar containing the missing class: " + scn);
252+
}
245253
//get all base methods and method names
246254
while (true) {
247255
for (Method m : currClass.getMethods()) {

dts-generator/src/main/java/com/telerik/dts/FileWriter.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public void write(String content, String fileName) {
3030
try {
3131
if(this.writeMultipleFiles) {
3232
this.ps = new PrintStream(new File(this.outDir.getAbsolutePath(), fileName + ".d.ts"));
33-
ps.print("/// <reference path=\"./_helpers.d.ts\" />");
33+
ps.println("/// <reference path=\"./_helpers.d.ts\" />");
3434
this.ps.print(content);
3535
}
3636
else {
@@ -39,7 +39,7 @@ public void write(String content, String fileName) {
3939

4040
//add helpers reference to the top of the file
4141
if(this.isFirstRun) {
42-
ps.print("/// <reference path=\"./_helpers.d.ts\" />");
42+
ps.println("/// <reference path=\"./_helpers.d.ts\" />");
4343
this.isFirstRun = false;
4444
}
4545

0 commit comments

Comments
 (0)