Browse Source

Added better logging in JavaNativeModule

Jared 5 years ago
parent
commit
191edd6cae
No account linked to committer's email address

+ 5
- 5
JavaIntegration/src/main/java/org/openzen/zencode/java/JavaNativeModule.java View File

214
 	
214
 	
215
 	public FunctionalMemberRef loadStaticMethod(Method method) {
215
 	public FunctionalMemberRef loadStaticMethod(Method method) {
216
 		if (!isStatic(method.getModifiers()))
216
 		if (!isStatic(method.getModifiers()))
217
-			throw new IllegalArgumentException("Method is not static");
217
+			throw new IllegalArgumentException("Method \"" + method.toString() + "\" is not static");
218
 		
218
 		
219
 		HighLevelDefinition definition = addClass(method.getDeclaringClass());
219
 		HighLevelDefinition definition = addClass(method.getDeclaringClass());
220
 		JavaClass jcls = JavaClass.fromInternalName(getInternalName(method.getDeclaringClass()), JavaClass.Kind.CLASS);
220
 		JavaClass jcls = JavaClass.fromInternalName(getInternalName(method.getDeclaringClass()), JavaClass.Kind.CLASS);
241
 		else if (className.startsWith(basePackage + "."))
241
 		else if (className.startsWith(basePackage + "."))
242
 			className = className.substring(basePackage.length() + 1);
242
 			className = className.substring(basePackage.length() + 1);
243
 		else
243
 		else
244
-			throw new IllegalArgumentException("Invalid class name: not in the given base package");
244
+            throw new IllegalArgumentException("Invalid class name: \"" + className + "\" not in the given base package: \"" + basePackage + "\"");
245
 		
245
 		
246
 		String[] classNameParts = Strings.split(className, '.');
246
 		String[] classNameParts = Strings.split(className, '.');
247
 		ZSPackage classPkg = pkg;
247
 		ZSPackage classPkg = pkg;
253
 	
253
 	
254
 	private <T> HighLevelDefinition convertClass(Class<T> cls) {
254
 	private <T> HighLevelDefinition convertClass(Class<T> cls) {
255
 		if ((cls.getModifiers() & Modifier.PUBLIC) == 0)
255
 		if ((cls.getModifiers() & Modifier.PUBLIC) == 0)
256
-			throw new IllegalArgumentException("Class must be public");
256
+			throw new IllegalArgumentException("Class \" " + cls.getName() + "\" must be public");
257
 		
257
 		
258
 		String className = cls.getName();
258
 		String className = cls.getName();
259
 		boolean isStruct = cls.getAnnotation(ZenCodeType.Struct.class) != null;
259
 		boolean isStruct = cls.getAnnotation(ZenCodeType.Struct.class) != null;
461
 	private OperatorMember asOperator(TypeVariableContext context, HighLevelDefinition definition, Method method, ZenCodeType.Operator annotation) {
461
 	private OperatorMember asOperator(TypeVariableContext context, HighLevelDefinition definition, Method method, ZenCodeType.Operator annotation) {
462
 		FunctionHeader header = getHeader(context, method);
462
 		FunctionHeader header = getHeader(context, method);
463
 		if (isStatic(method.getModifiers()))
463
 		if (isStatic(method.getModifiers()))
464
-			throw new IllegalArgumentException("operator method cannot be static");
464
+			throw new IllegalArgumentException("operator method \"" + method.toString() + "\"cannot be static");
465
 		
465
 		
466
 		// TODO: check number of parameters
466
 		// TODO: check number of parameters
467
 		//if (header.parameters.length != annotation.value().parameters)
467
 		//if (header.parameters.length != annotation.value().parameters)
488
 	
488
 	
489
 	private SetterMember asSetter(TypeVariableContext context, HighLevelDefinition definition, Method method, ZenCodeType.Setter annotation) {
489
 	private SetterMember asSetter(TypeVariableContext context, HighLevelDefinition definition, Method method, ZenCodeType.Setter annotation) {
490
 		if (method.getParameterCount() != 1)
490
 		if (method.getParameterCount() != 1)
491
-			throw new IllegalArgumentException("Illegal setter: must have exactly 1 parameter");
491
+			throw new IllegalArgumentException("Illegal setter: \"" + method.toString() + "\"must have exactly 1 parameter");
492
 		
492
 		
493
 		StoredType type = loadStoredType(context, method.getAnnotatedParameterTypes()[0]);
493
 		StoredType type = loadStoredType(context, method.getAnnotatedParameterTypes()[0]);
494
 		String name = null;
494
 		String name = null;

Loading…
Cancel
Save