diff options
-rw-r--r-- | src/com/jogamp/opencl/CLException.java | 20 | ||||
-rw-r--r-- | test/com/jogamp/opencl/CLExceptionTest.java | 37 |
2 files changed, 54 insertions, 3 deletions
diff --git a/src/com/jogamp/opencl/CLException.java b/src/com/jogamp/opencl/CLException.java index e7133994..4955cc42 100644 --- a/src/com/jogamp/opencl/CLException.java +++ b/src/com/jogamp/opencl/CLException.java @@ -14,8 +14,9 @@ public class CLException extends RuntimeException { public final int errorcode; public final String error; - private final static String ERROR_CODE_DOC = - "http://www.khronos.org/opencl/sdk/1.1/docs/man/xhtml/errors.html"; + //man page no longer exists +// private final static String ERROR_CODE_DOC = +// "http://www.khronos.org/opencl/sdk/1.1/docs/man/xhtml/errors.html"; public CLException(String message) { super(message); @@ -24,7 +25,7 @@ public class CLException extends RuntimeException { } private CLException(int errorcode, String errorStr, String message) { - super(message + "\nerror: " + errorStr + " (man page: "+ERROR_CODE_DOC+")"); + super(message + "\nerror: " + errorStr/* + " (man page: "+ERROR_CODE_DOC+")"*/); this.error = errorStr; this.errorcode = errorcode; } @@ -113,6 +114,7 @@ public class CLException extends RuntimeException { case CL_INVALID_BUFFER_SIZE: return "CL_INVALID_BUFFER_SIZE"; case CL_INVALID_MIP_LEVEL: return "CL_INVALID_MIP_LEVEL"; case CL_INVALID_GLOBAL_WORK_SIZE: return "CL_INVALID_GLOBAL_WORK_SIZE"; + case CL_INVALID_PROPERTY: return "CL_INVALID_PROPERTY"; case CL_INVALID_GL_SHAREGROUP_REFERENCE_KHR: return "CL_INVALID_GL_SHAREGROUP_REFERENCE_KHR"; case CL_PLATFORM_NOT_FOUND_KHR: return "CL_PLATFORM_NOT_FOUND_KHR"; case CL_MISALIGNED_SUB_BUFFER_OFFSET: return "CL_MISALIGNED_SUB_BUFFER_OFFSET"; @@ -169,6 +171,7 @@ public class CLException extends RuntimeException { case CL_INVALID_BUFFER_SIZE: return new CLInvalidBufferSizeException(message); case CL_INVALID_MIP_LEVEL: return new CLInvalidMipLevelException(message); case CL_INVALID_GLOBAL_WORK_SIZE: return new CLInvalidGlobalWorkSizeException(message); + case CL_INVALID_PROPERTY: return new CLInvalidPropertyException(message); case CL_INVALID_GL_SHAREGROUP_REFERENCE_KHR: return new CLInvalidGLSharegroupReferenceKhrException(message); case CL_PLATFORM_NOT_FOUND_KHR: return new CLPlatformNotFoundKhrException(message); case CL_MISALIGNED_SUB_BUFFER_OFFSET: return new CLMisalignedSubBufferOffsetException(message); @@ -684,6 +687,17 @@ public class CLException extends RuntimeException { } /** + * {@link CLException} thrown on CL.CL_INVALID_PROPERTY errors. + * @author Michael Bien + */ + public final static class CLInvalidPropertyException extends CLException { + private static final long serialVersionUID = CLException.serialVersionUID+CL_INVALID_PROPERTY; + public CLInvalidPropertyException(String message) { + super(CL_INVALID_PROPERTY, "CL_INVALID_PROPERTY", message); + } + } + + /** * {@link CLException} thrown on CL.CL_INVALID_GL_SHAREGROUP_REFERENCE_KHR errors. * @author Michael Bien */ diff --git a/test/com/jogamp/opencl/CLExceptionTest.java b/test/com/jogamp/opencl/CLExceptionTest.java new file mode 100644 index 00000000..f6d7ca7b --- /dev/null +++ b/test/com/jogamp/opencl/CLExceptionTest.java @@ -0,0 +1,37 @@ + +package com.jogamp.opencl; + +import java.lang.reflect.InvocationTargetException; +import org.junit.Test; +import static org.junit.Assert.*; + +/** + * + * @author Michael Bien + */ +public class CLExceptionTest { + + @Test + public void testCLExceptions() throws InstantiationException, IllegalAccessException, NoSuchMethodException, IllegalArgumentException, InvocationTargetException { + Class<?>[] subTypes = CLException.class.getDeclaredClasses(); + + for (Class<?> type : subTypes) { + + if(type.getName().startsWith(CLException.class.getName()+"$CL")) { + + CLException exception = (CLException) type.getConstructor(String.class).newInstance("foo"); + + assertNotNull("can not resolve "+exception, CLException.resolveErrorCode(exception.errorcode)); + + try{ + CLException.checkForError(exception.errorcode, "foo"); + fail("expected exception for: "+exception.getClass().getName()+" code: "+exception.errorcode); + }catch(CLException ex) { + assertTrue("wrong instance; expected "+exception.getClass()+" but got "+ex.getClass(), + exception.getClass().equals(ex.getClass())); + } + } + } + } + +} |