Examples of ExceptionContext


Examples of com.cedarsolutions.exception.context.ExceptionContext

    /** Test generateExceptionContext(). */
    @Test public void testGenerateExceptionContext() {
        // This test is very sensitive to line numbers, so if you edit stuff above (even organize imports), this will fail

        ExceptionContext context;
        String expected;

        context = ExceptionUtils.generateExceptionContext(null, 0);
        assertNull(context);

        Exception exception = new Exception("Hello", null);
        context = ExceptionUtils.generateExceptionContext(exception, 0);
        expected = "com.cedarsolutions.util.ExceptionUtilsTest.testGenerateExceptionContext(ExceptionUtilsTest.java:85)";
        assertEquals(expected, context.getLocation());
        assertNotNull(context.getStackTrace());
        assertNull(context.getRootCause());

        Exception cause = new Exception("I am a cause");
        exception = new Exception("Hello", cause);
        context = ExceptionUtils.generateExceptionContext(exception, 0);
        expected = "com.cedarsolutions.util.ExceptionUtilsTest.testGenerateExceptionContext(ExceptionUtilsTest.java:93)";
        assertEquals(expected, context.getLocation());
        assertNotNull(context.getStackTrace());
        assertEquals(ExceptionUtils.generateRootCause(cause), context.getRootCause());

        // note: line number should be marked as if it came from the line below, not the method call
        exception = createException();
        context = ExceptionUtils.generateExceptionContext(exception, 1);
        expected = "com.cedarsolutions.util.ExceptionUtilsTest.testGenerateExceptionContext(ExceptionUtilsTest.java:101)";
        assertEquals(expected, context.getLocation());
        assertNotNull(context.getStackTrace());
        assertNull(context.getRootCause());
    }
View Full Code Here

Examples of com.cedarsolutions.exception.context.ExceptionContext

        assertEquals(null, GwtExceptionUtils.generateStackTrace(null));

        CedarRuntimeException e = new CedarRuntimeException();
        assertNotNull(GwtExceptionUtils.generateStackTrace(e));

        e.setContext(new ExceptionContext());
        assertNotNull(GwtExceptionUtils.generateStackTrace(e));

        e.getContext().setStackTrace("X");
        assertEquals("X", GwtExceptionUtils.generateStackTrace(e));
View Full Code Here

Examples of com.cedarsolutions.exception.context.ExceptionContext

            assertSame(cause, e.getCause());
            assertFalse(e.hasContext());
            assertNull(e.getContext());
        }

        ExceptionContext context = new ExceptionContext();
        CedarException e = new CedarException(message, cause);
        e.setContext(context);
        assertTrue(e.hasContext());
        assertSame(context, e.getContext());
    }
View Full Code Here

Examples of com.cedarsolutions.exception.context.ExceptionContext

            assertSame(cause, e.getCause());
            assertFalse(e.hasContext());
            assertNull(e.getContext());
        }

        ExceptionContext context = new ExceptionContext();
        CedarRuntimeException e = new CedarRuntimeException(message, cause);
        e.setContext(context);
        assertTrue(e.hasContext());
        assertSame(context, e.getContext());
    }
View Full Code Here

Examples of com.cedarsolutions.exception.context.ExceptionContext

     */
    @SuppressWarnings("unchecked")
    public static <T> T addExceptionContext(Throwable exception, int level) {
        if (exception instanceof IHasExceptionContext) {
            IHasExceptionContext hasContext = (IHasExceptionContext) exception;
            ExceptionContext context = generateExceptionContext(exception, level);
            hasContext.setContext(context);
        }

        return (T) exception;
    }
View Full Code Here

Examples of com.cedarsolutions.exception.context.ExceptionContext

    /** Generate the exception context for an exception. */
    public static ExceptionContext generateExceptionContext(Throwable exception, int level) {
        if (exception == null) {
            return null;
        } else {
            ExceptionContext context = new ExceptionContext();

            context.setLocation(getLocation(exception, level));
            context.setStackTrace(generateStackTrace(exception));
            context.setRootCause(generateRootCause(exception.getCause()));

            return context;
        }
    }
View Full Code Here

Examples of org.apache.commons.math3.exception.util.ExceptionContext

                                              double threshold) {
        super(wrong, threshold, false);
        this.index = index;
        this.threshold = threshold;

        final ExceptionContext context = getContext();
        context.addMessage(LocalizedFormats.NOT_POSITIVE_DEFINITE_MATRIX);
        context.addMessage(LocalizedFormats.ARRAY_ELEMENT, wrong, index);
    }
View Full Code Here

Examples of org.apache.commons.math3.exception.util.ExceptionContext

            final double t = x.dotProduct(z);
            final double epsa = (s + MACH_PREC) * CBRT_MACH_PREC;
            if (FastMath.abs(s - t) > epsa) {
                final NonSelfAdjointOperatorException e;
                e = new NonSelfAdjointOperatorException();
                final ExceptionContext context = e.getContext();
                context.setValue(SymmLQ.OPERATOR, l);
                context.setValue(SymmLQ.VECTOR1, x);
                context.setValue(SymmLQ.VECTOR2, y);
                context.setValue(SymmLQ.THRESHOLD, Double.valueOf(epsa));
                throw e;
            }
        }
View Full Code Here

Examples of org.apache.commons.math3.exception.util.ExceptionContext

         */
        private static void throwNPDLOException(final RealLinearOperator l,
            final RealVector v) throws NonPositiveDefiniteOperatorException {
            final NonPositiveDefiniteOperatorException e;
            e = new NonPositiveDefiniteOperatorException();
            final ExceptionContext context = e.getContext();
            context.setValue(OPERATOR, l);
            context.setValue(VECTOR, v);
            throw e;
        }
View Full Code Here

Examples of org.apache.commons.math3.exception.util.ExceptionContext

     * @param pattern Message pattern explaining the cause of the error.
     * @param args Arguments.
     */
    public MathIllegalArgumentException(Localizable pattern,
                                        Object ... args) {
        context = new ExceptionContext(this);
        context.addMessage(pattern, args);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.