Example usage for java.lang Error Error

List of usage examples for java.lang Error Error

Introduction

In this page you can find the example usage for java.lang Error Error.

Prototype

public Error() 

Source Link

Document

Constructs a new error with null as its detail message.

Usage

From source file:net.larry1123.util.api.world.blocks.BlockPropertyStorage.java

public BlockPropertyStorage(String json) throws ParseException, ClassNotFoundException {
    // TODO add a bit of validation
    JSONParser parser = new JSONParser();
    JSONObject jsonObject = (JSONObject) parser.parse(json);
    name = (String) jsonObject.get("keyName");
    blockTypeMachineName = (String) jsonObject.get("blockTypeMachineName");
    blockTypeData = (Short) jsonObject.get("blockTypeData");
    try {//from  ww w  .j a  v  a2  s.  co  m
        byte[] bytes = Base64.decodeBase64((String) jsonObject.get("value"));
        ObjectInputStream objectInputStream = new ObjectInputStream(new ByteArrayInputStream(bytes));
        value = (Comparable) objectInputStream.readObject();
    } catch (IOException e) {
        throw new Error();
        // Not sure how that could happen but I will see what I may need to do
    }
}

From source file:com.planet57.gshell.util.cli2.OptionDescriptor.java

/**
 * Returns the option syntax, sans optional token if option takes an argument.
 *//*w ww. ja  va 2  s  . c om*/
public String getSyntax() {
    if (name != null && longName != null) {
        return String.format("-%s (--%s)", name, longName);
    } else if (name != null) {
        return String.format("-%s", name);
    } else if (longName != null) {
        return String.format("--%s", longName);
    }
    throw new Error();
}

From source file:me.zhuoran.amoeba.netty.server.http.HttpRequestHandler.java

/**
 * sanitize url//from   ww  w  .java2 s  .  c  o m
 * @param uri
 * @return
 * @throws URISyntaxException
 */
public static String sanitizeUri(String uri) throws URISyntaxException {
    try {
        uri = URLDecoder.decode(uri, "UTF-8");
    } catch (UnsupportedEncodingException var4) {
        try {
            uri = URLDecoder.decode(uri, "ISO-8859-1");
        } catch (UnsupportedEncodingException var3) {
            throw new Error();
        }
    }

    if (!uri.startsWith("/")) {
        return null;
    } else {
        URI uriObject = new URI(uri);

        for (uri = uriObject.getPath(); uri != null && uri.startsWith("/"); uri = uri.substring(1)) {
        }

        return uri.toLowerCase();
    }
}

From source file:shiver.me.timbers.security.spring.StatelessAuthenticationSuccessHandlerTest.java

@Test
public void Can_map_thrown_error() throws Exception {

    final HttpServletRequest request = mock(HttpServletRequest.class);
    final HttpServletResponse response = mock(HttpServletResponse.class);
    final Authentication authentication = mock(Authentication.class);

    final Error error = new Error();

    // Given// ww w .  j a v  a 2 s .c  om
    willThrow(error).given(httpServletBinder).add(response, authentication);

    // When
    handler.onAuthenticationSuccess(request, response, authentication);

    // Then
    verify(exceptionMapper).throwMapped(error);
}

From source file:org.zodiark.service.EndpointUtils.java

public boolean validate(T p, Envelope e) {
    if (p == null) {
        error(e, p, errorMessage(writeAsString(new Error().error("Unauthorized")), e.getMessage().getUUID()));
        return false;
    }//from w  w w  .  j  a  v a 2s.co  m
    return true;
}

From source file:org.zodiark.service.EndpointUtils.java

public boolean validateShowId(T p, Envelope e) {
    if (p == null) {
        error(e, p, constructMessage(e.getMessage().getPath(), writeAsString(new Error().error("Unauthorized")),
                e.getMessage().getUUID()));
        return false;
    }//from w w  w  . j a  v a 2  s.c o  m
    return true;
}

From source file:com.antsdb.saltedfish.sql.mysql.Set_stmtGenerator.java

private Instruction genSetVariables(GeneratorContext ctx, Set_stmt_variableContext rule) {
    Flow flow = new Flow();
    for (Variable_assignmentContext i : rule.variable_assignment()) {
        Instruction set = null;// ww w.  j a  v a 2s  .  co  m
        if (i.variable_assignment_user() != null) {
            set = createSetUserVariable(ctx, i.variable_assignment_user());
        } else if (i.variable_assignment_session() != null) {
            set = createSetSessionVariable(ctx, i.variable_assignment_session());
        } else if (i.variable_assignment_global() != null) {
            set = createSetGlobalVariable(ctx, i.variable_assignment_global());
        } else if (i.variable_assignment_session_transaction() != null) {
            set = createSetSessionTransaction(ctx, i.variable_assignment_session_transaction());
        } else if (i.variable_assignment_global_transaction() != null) {
            set = createSetGlobalTransaction(ctx, i.variable_assignment_global_transaction());
        } else if (i.variable_assignment_transaction() != null) {
            set = createSetTransaction(ctx, i.variable_assignment_transaction());
        } else {
            throw new Error();
        }
        flow.add(set);
    }
    return flow;
}

From source file:shiver.me.timbers.security.spring.StatelessAuthenticationFilterTest.java

@Test
public void Can_map_thrown_error() throws Exception {

    final HttpServletRequest request = mock(HttpServletRequest.class);
    final ServletResponse response = mock(ServletResponse.class);
    final FilterChain filterChain = mock(FilterChain.class);

    final SecurityContext securityContext = mock(SecurityContext.class);

    final Error error = new Error();

    // Given//from   w  ww  .  j a  va  2 s  . c  o  m
    given(contextHolder.getContext()).willReturn(securityContext);
    given(httpServletBinder.retrieve(request)).willThrow(error);

    // When
    filter.doFilter(request, response, filterChain);

    // Then
    verify(exceptionMapper).throwMapped(error);
}

From source file:hudson.plugins.testlink.parser.junit.JUnitXmlHandler.java

@Override
public void startElement(String uri, String localName, String qName, Attributes attributes)
        throws SAXException {
    if ("testsuite".equals(qName)) {
        tempVal = new StringBuilder();
        testSuite = new TestSuite();

        Long errors = 0L;/*from ww w .  jav  a2s .  com*/
        String errorsValue = attributes.getValue("errors");
        if (StringUtils.isNotBlank(errorsValue)) {
            errors = Long.parseLong(errorsValue);
        }
        testSuite.setErrors(errors);

        Long failures = 0L;
        String failuresValue = attributes.getValue("failures");
        if (StringUtils.isNotBlank(failuresValue)) {
            failures = Long.parseLong(failuresValue);
        }
        testSuite.setFailures(failures);
        testSuite.setHostname(attributes.getValue("hostname"));
        testSuite.setName(attributes.getValue("name"));
        testSuite.setSystemErr(attributes.getValue(""));
        testSuite.setSystemOut(attributes.getValue(""));
        testSuite.setTests(attributes.getValue("tests"));
        testSuite.setTime(attributes.getValue("time"));
        testSuite.setTimestamp(attributes.getValue("timestamp"));
    } else if ("testcase".equals(qName)) {
        tempVal = new StringBuilder();
        testCase = new TestCase();

        testCase.setClassName(attributes.getValue("classname"));
        testCase.setName(attributes.getValue("name"));
        testCase.setTime(attributes.getValue("time"));
    } else if ("failure".equals(qName)) {
        tempVal = new StringBuilder();
        failure = new Failure();
        failure.setMessage(attributes.getValue("message"));
        failure.setType(attributes.getValue("type"));
    } else if ("error".equals(qName)) {
        tempVal = new StringBuilder();
        error = new Error();
        error.setMessage(attributes.getValue("message"));
        error.setType(attributes.getValue("type"));
    } else if ("system-out".equals(qName)) {
        tempVal = new StringBuilder();
    } else if ("system-err".equals(qName)) {
        tempVal = new StringBuilder();
    }
}

From source file:me.everything.providers.stetho.Database.java

private JsonRpcResult executeSQL(String databaseId, String query) {

    ExecuteSQLResponse response = new ExecuteSQLResponse();

    try {/*from   w  w w .  j ava 2  s .  c o m*/

        QueryResolver queryResolver = new QueryResolver(query);
        String tableName = queryResolver.tableName;

        String[] columns = mProvidersPeerManager.getColumns(databaseId, tableName);
        List<? extends Entity> entities = mProvidersPeerManager.getEntites(databaseId, tableName, query);

        response.columnNames = Arrays.asList(columns);
        response.values = flattenRows(columns, entities);

    } catch (Exception e) {
        Error error = new Error();
        error.message = e.getMessage();
        error.code = 8000;
        response.sqlError = error;
    }

    return response;
}