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:ImageUtil.java

/**
 * Returns an image resource./*from  ww  w  .  java2s  .  c o m*/
 *
 * @param filename the filename of the image to load
 * @return the loaded image
 */
public static Image getImage(String filename) {
    URL url = ImageUtil.class.getResource(filename);

    if (url == null) {
        return null;
    }

    try {
        final BufferedImage result = ImageIO.read(url);

        if (result == null) {
            final String message = "Could not load image: " + filename;
            throw new Error();
        }
        return result;
    } catch (IOException e) {
        return null;
    }

}

From source file:Main.java

/**
 * What a Terrible Failure: Report a condition that should never happen.
 * The error will always be logged at level ASSERT with the call stack.
 * Depending on system configuration, a report may be added to the
 * {@link android.os.DropBoxManager} and/or the process may be terminated
 * immediately with an error dialog./*from w  w  w . ja  v  a2s .  c  o m*/
 * @param tag Used to identify the source of a log message.  It usually identifies
 *        the class or activity where the log call occurs.
 * @param format the format string (see {@link java.util.Formatter#format})
 * @param args
 *            the list of arguments passed to the formatter. If there are
 *            more arguments than required by {@code format},
 *            additional arguments are ignored.
 */
public static int wtf(String tag, String format, Object... args) {
    return Log.wtf(tag, String.format(format, args), new Error());
}

From source file:org.apache.samza.sql.master.rest.providers.JsonProcessingExceptionMapper.java

@Override
public Response toResponse(JsonProcessingException exception) {
    Error error = new Error();
    error.key = "bad-json";
    error.message = exception.getMessage();
    return Response.status(Status.BAD_REQUEST).entity(error).build();
}

From source file:cz.jirutka.spring.exhandler.messages.ValidationErrorMessage.java

public ValidationErrorMessage addError(String field, Object rejectedValue, String message) {
    Error error = new Error();
    error.field = field;/*from   w  w w.  ja va 2s .c  om*/
    error.rejected = rejectedValue;
    error.message = message;

    errors.add(error);
    return this;
}

From source file:cz.jirutka.spring.exhandler.messages.ValidationErrorMessage.java

public ValidationErrorMessage addError(String message) {
    Error error = new Error();
    error.message = message;// w  ww.j  av  a 2 s .  c o  m

    errors.add(error);
    return this;
}

From source file:com.grapeshot.halfnes.FileUtils.java

public static int[] readfromfile(final InputStream inputStream) {
    try {/*w  w  w  .  j  a v  a2 s.  c om*/
        byte[] bytes = IOUtils.toByteArray(inputStream);

        int[] ints = new int[bytes.length];

        for (int i = 0; i < bytes.length; i++) {
            ints[i] = (short) (bytes[i] & 0xFF);
        }

        return ints;
    } catch (IOException e) {
        throw new Error();
    }
}

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

public void statusEvent(final String path, final Envelope e, final T p) {

    if (!validateAll(p, e))
        ;//from   w  w w. j av  a 2s  . c om

    statusEvent(path, e, p, new Reply<Status, String>() {
        @Override
        public void ok(Status status) {
            logger.trace("Status {}", status);
            response(e, p, constructMessage(path, writeAsString(status), e.getMessage().getUUID()));
        }

        @Override
        public void fail(ReplyException replyException) {
            error(e, p,
                    errorMessage(writeAsString(new Error().error("Unauthorized")), e.getMessage().getUUID()));
        }
    });
}

From source file:com.almende.eve.capabilities.AbstractCapabilityBuilder.java

/**
 * Builds or retrieves the Capability.//w  w  w . j a  va  2 s  .c o  m
 * 
 * @return the t
 */
public T build() {
    final Config params = Config.decorate(parameters);
    final String className = params.getClassName();
    if (className != null) {
        try {
            final Class<?> clazz = Class.forName(className, true, cl);
            if (ClassUtil.hasSuperClass(clazz, AbstractCapabilityBuilder.class)) {
                @SuppressWarnings("unchecked")
                final AbstractCapabilityBuilder<T> instance = (AbstractCapabilityBuilder<T>) clazz
                        .newInstance();
                return instance.withClassLoader(cl).withConfig(parameters).withHandle(handle).build();
            } else {
                LOG.log(Level.WARNING, className + " is not a CapabilityBuilder, which is required.");
                throw new Error();
            }
        } catch (final ClassNotFoundException e) {
            LOG.log(Level.WARNING, "Couldn't find class:" + className, e);
        } catch (InstantiationException e) {
            LOG.log(Level.WARNING, "Couldn't instantiate class:" + className, e);
        } catch (final SecurityException e) {
            LOG.log(Level.WARNING, "Couldn't access class:" + className + " methods", e);
        } catch (final IllegalAccessException e) {
            LOG.log(Level.WARNING, "Couldn't access class:" + className + " methods", e);
        } catch (final IllegalArgumentException e) {
            LOG.log(Level.WARNING, "Method of class:" + className + " has incorrect arguments", e);
        }
    } else {
        LOG.warning("Parameter 'class' is required, incomplete config:" + params.toString());
    }
    return null;
}

From source file:com.oddprints.servlets.Edit.java

@GET
@Path("/basic")
@Produces(MediaType.TEXT_HTML)/*from ww  w  . j a  va 2  s  .  co  m*/
public Viewable viewBasic(@Context HttpServletRequest req) {
    PersistenceManager pm = PMF.get().getPersistenceManager();

    Basket basket = Basket.fromSession(req, pm);

    Map<String, Object> it = Maps.newHashMap();
    it.put("basket", basket);

    String blobSizeString = (String) req.getSession().getAttribute("blobSize");
    if (blobSizeString == null) {
        return new Error().get("No image found");
    }

    req.getSession().setAttribute("basicMode", Boolean.TRUE);
    return new Viewable("/edit-basic", it);
}

From source file:org.apache.solr.update.StreamingSolrServers.java

public synchronized SolrServer getSolrServer(final SolrCmdDistributor.Req req) {
    String url = getFullUrl(req.node.getUrl());
    ConcurrentUpdateSolrServer server = solrServers.get(url);
    if (server == null) {
        server = new ConcurrentUpdateSolrServer(url, httpClient, 100, 1, updateExecutor, true) {
            @Override//from  ww w .j av a  2s.c  o m
            public void handleError(Throwable ex) {
                req.trackRequestResult(null, false);
                log.error("error", ex);
                Error error = new Error();
                error.e = (Exception) ex;
                if (ex instanceof SolrException) {
                    error.statusCode = ((SolrException) ex).code();
                }
                error.req = req;
                errors.add(error);
            }

            @Override
            public void onSuccess(HttpResponse resp) {
                req.trackRequestResult(resp, true);
            }
        };
        server.setParser(new BinaryResponseParser());
        server.setRequestWriter(new BinaryRequestWriter());
        server.setPollQueueTime(0);
        Set<String> queryParams = new HashSet<>(2);
        queryParams.add(DistributedUpdateProcessor.DISTRIB_FROM);
        queryParams.add(DistributingUpdateProcessorFactory.DISTRIB_UPDATE_PARAM);
        server.setQueryParams(queryParams);
        solrServers.put(url, server);
    }

    return server;
}