Examples of ExceptionMessage


Examples of org.candlepin.common.exceptions.ExceptionMessage

    @Test
    public void candlepinException() {
        CandlepinException ce = mock(CandlepinException.class);
        when(ce.httpReturnCode()).thenReturn(Status.CONFLICT);
        ExceptionMessage em = new ExceptionMessage().setDisplayMessage("you screwed up");
        when(ce.message()).thenReturn(em);
        when(req.getHeader(HttpHeaderNames.ACCEPT)).thenReturn("application/json");

        assertEquals("you screwed up", em.toString());
        Response r = rem.toResponse(ce);
        assertNotNull(r);
        assertEquals(Status.CONFLICT.getStatusCode(), r.getStatus());
        verifyMessage(r, "you screwed up");
    }
View Full Code Here

Examples of org.candlepin.common.exceptions.ExceptionMessage

    @Test
    public void candlepinExceptionWithChildNotCandleping() {
        CandlepinException ce = mock(CandlepinException.class);
        when(ce.httpReturnCode()).thenReturn(Status.CONFLICT);
        when(ce.message()).thenReturn(
            new ExceptionMessage().setDisplayMessage("you screwed up"));
        when(req.getHeader(HttpHeaderNames.ACCEPT)).thenReturn("application/json");
        when(ce.getCause()).thenReturn(new ConflictException("you screwed up"));
        Response r = rem.toResponse(ce);
        assertNotNull(r);
        assertEquals(Status.CONFLICT.getStatusCode(), r.getStatus());
View Full Code Here

Examples of org.candlepin.common.exceptions.ExceptionMessage

        }

        Map<String, String> map = VersionUtil.getVersionMap();

        return Response.status(status)
            .entity(new ExceptionMessage(message))
            .type(responseMediaType)
            .header(VersionUtil.VERSION_HEADER,
                map.get("version") + "-" + map.get("release"));
    }
View Full Code Here

Examples of org.candlepin.common.exceptions.ExceptionMessage

        if (cause instanceof CandlepinParamterParseException) {
            String msg = i18n.get().tr("Invalid format for query parameter {0}. " +
                "Expected format: {1}",
                ((CandlepinParamterParseException) cause).getParamName(),
                ((CandlepinParamterParseException) cause).getExpectedFormat());
            bldr.entity(new ExceptionMessage(msg));
        }
        else {
            String msg = exception.getMessage();
            if (StringUtils.isNotEmpty(msg)) {
                bldr.entity(new ExceptionMessage(extractIllegalValue(msg)));
            }
        }
        return bldr.build();
    }
View Full Code Here

Examples of org.candlepin.common.exceptions.ExceptionMessage

                ((ConstraintViolationException) exception).getConstraintViolations()) {
                message.append(cv.getPropertyPath().toString());
                message.append(": ");
                message.append(cv.getMessage());
            }
            bldr.entity(new ExceptionMessage(message.toString()));
        }
        else {
            getDefaultBuilder(exception, Response.Status.BAD_REQUEST, determineBestMediaType());
        }
        return bldr.build();
View Full Code Here

Examples of org.candlepin.common.exceptions.ExceptionMessage

        IOException ioe = new IOException("fake io exception");
        RuntimeException re = new RuntimeException("oops", ioe);
        ResponseBuilder bldr = cem.getDefaultBuilder(re, null,
            MediaType.APPLICATION_ATOM_XML_TYPE);
        Response r = bldr.build();
        ExceptionMessage em = (ExceptionMessage) r.getEntity();

        assertEquals(Status.INTERNAL_SERVER_ERROR.getStatusCode(), r.getStatus());
        assertEquals(MediaType.APPLICATION_ATOM_XML_TYPE,
            r.getMetadata().get("Content-Type").get(0));
        assertTrue(em.getDisplayMessage().startsWith("Runtime Error " + re.getMessage()));
    }
View Full Code Here

Examples of org.candlepin.common.exceptions.ExceptionMessage

        // simulate Java 7 on a Java 6 vm
        when(nostack.getStackTrace()).thenReturn(null);

        Response r = cem.getDefaultBuilder(nostack, null,
            MediaType.APPLICATION_JSON_TYPE).build();
        ExceptionMessage em = (ExceptionMessage) r.getEntity();

        assertEquals(Status.INTERNAL_SERVER_ERROR.getStatusCode(), r.getStatus());
        assertEquals("Runtime Error no stack trace", em.getDisplayMessage());
        assertEquals(MediaType.APPLICATION_JSON_TYPE,
            r.getMetadata().get("Content-Type").get(0));
    }
View Full Code Here

Examples of org.candlepin.common.exceptions.ExceptionMessage

    protected String rtmsg(String msg) {
        return "Runtime Error " + msg;
    }

    protected void verifyMessage(Response r, String expectedmsg) {
        ExceptionMessage em = (ExceptionMessage) r.getEntity();

        assertNotNull(em);
        assertTrue(expectedmsg,
            em.getDisplayMessage().startsWith(expectedmsg));
    }
View Full Code Here

Examples of org.codehaus.groovy.control.messages.ExceptionMessage

                Object ret = method.invoke(null, new Object[]{javacParameters});
                javacReturnValue = ((Integer) ret).intValue();
            }
            cu.getConfiguration().getOutput();
        } catch (Exception e) {
            cu.getErrorCollector().addFatalError(new ExceptionMessage(e, true, cu));
        }
        if (javacReturnValue!=0) {
            switch (javacReturnValue) {
                case 1: addJavacError("Compile error during compilation with javac.",cu,javacOutput); break;
                case 2: addJavacError("Invalid commandline usage for javac.",cu,javacOutput); break;
View Full Code Here

Examples of org.codehaus.groovy.control.messages.ExceptionMessage

            cls = loader.loadClass(name, false, true);
        } catch (ClassNotFoundException cnfe) {
            cachedClasses.put(name, SCRIPT);
            return false;
        } catch (CompilationFailedException cfe) {
            compilationUnit.getErrorCollector().addErrorAndContinue(new ExceptionMessage(cfe, true, source));
            return false;
        }
        //TODO: the case of a NoClassDefFoundError needs a bit more research
        // a simple recompilation is not possible it seems. The current class
        // we are searching for is there, so we should mark that somehow.
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.