Package com.cedarsolutions.exception.context

Examples of com.cedarsolutions.exception.context.RootCause


    @Test public void testGenerateRootCause() {
        Throwable nested = new IllegalAccessException("nested");
        Throwable cause1 = new Exception("cause1");
        Throwable cause2 = new Exception("cause2", nested);

        RootCause rootCause = ExceptionUtils.generateRootCause(cause1);
        assertNotNull(rootCause);
        assertEquals(cause1.getClass().getName(), rootCause.getName());
        assertEquals(cause1.getClass().getCanonicalName(), rootCause.getCanonicalName());
        assertEquals(cause1.getClass().getSimpleName(), rootCause.getSimpleName());
        assertEquals(cause1.getMessage(), rootCause.getMessage());
        assertNull(rootCause.getCause());

        rootCause = ExceptionUtils.generateRootCause(cause2);
        assertEquals(cause2.getClass().getName(), rootCause.getName());
        assertEquals(cause2.getClass().getCanonicalName(), rootCause.getCanonicalName());
        assertEquals(cause1.getClass().getSimpleName(), rootCause.getSimpleName());
        assertEquals(cause2.getMessage(), rootCause.getMessage());
        assertNotNull(rootCause.getCause());
        assertEquals(nested.getClass().getName(), rootCause.getCause().getName());
        assertEquals(nested.getClass().getCanonicalName(), rootCause.getCause().getCanonicalName());
        assertEquals(nested.getClass().getSimpleName(), rootCause.getCause().getSimpleName());
        assertEquals(nested.getMessage(), rootCause.getCause().getMessage());
    }
View Full Code Here


            String name = exception.getClass().getName();
            String canonicalName = exception.getClass().getCanonicalName();
            String simpleName = exception.getClass().getSimpleName();
            String message = exception.getMessage();
            String location = getLocation(exception);
            RootCause cause = generateRootCause(exception.getCause());
            return new RootCause(name, canonicalName, simpleName, message, location, cause);
        }
    }
View Full Code Here

TOP

Related Classes of com.cedarsolutions.exception.context.RootCause

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.