@Provider public class BadURIExceptionMapper implements ExceptionMapper<NotFoundException> { public Response toResponse(NotFoundException exception){ return Response.status(Response.Status.NOT_FOUND). entity(new ErrorResponse(exception.getClass().toString(), exception.getMessage()) ). build(); } }
@Override public Response toResponse(NotFoundException exception) { // if there is an optional exception message, we add it to the response if (exception.getMessage() != null) { return Response.status(Response.Status.NOT_FOUND).entity(exception.getMessage()).build(); } return Response.status(Response.Status.NOT_FOUND).build(); } }
@Override public Response toResponse(NotFoundException exception) { // if there is an optional exception message, we add it to the response if (exception.getMessage() != null) { return Response.status(Response.Status.NOT_FOUND).entity(exception.getMessage()).build(); } return Response.status(Response.Status.NOT_FOUND).build(); } }
@Override public Response toResponse(NotFoundException e) { return Response.status(Status.NOT_FOUND) .entity(e.getMessage()) .type(MediaType.TEXT_PLAIN) .build(); }
private void attachGridViewFragment(int headerFrag) { FragmentManager fragMgr = getSupportFragmentManager(); FragmentTransaction xact = fragMgr.beginTransaction(); try { if (findViewById(headerFrag) != null) { Resources res = getResources(); String title = res.getString(R.string.app_icon_name); xact.replace(headerFrag, new GridViewFragment(title, true, true), HEADER_FRAGMENT_TAG).commitAllowingStateLoss(); } } catch (NotFoundException e) { // TODO Auto-generated catch block Log.e("MyActivityName", e.getMessage()); } }
@Override public Response toResponse(NotFoundException exception) { LOGGER.debug("Resource not found.", exception); Map<String, Object> errorResponse = new HashMap<>(); errorResponse.put("message", exception.getMessage()); return Response.status(Response.Status.NOT_FOUND) .entity(errorResponse) .type(MediaType.APPLICATION_JSON_TYPE) .build(); } }
@Override public Response toResponse(NotFoundException exception) { LOGGER.debug("Resource not found.", exception); Map<String, Object> errorResponse = new HashMap<>(); errorResponse.put("message", exception.getMessage()); return Response.status(Response.Status.NOT_FOUND) .entity(errorResponse) .type(MediaType.APPLICATION_JSON_TYPE) .build(); } }
public Response toResponse(NotFoundException e) { System.out.println("Exception mapper successfully got an exception: " + e + ":" + e.getMessage()); System.out.println("Client IP is " + RpcContext.getContext().getRemoteAddressString()); return Response.status(Response.Status.NOT_FOUND).entity("Oops! the requested resource is not found!").type("text/plain").build(); } }
@Override public Response toResponse(NotFoundException ex){ String uri = request.getRequestURI(); String exMessage = ex.getMessage(); String outputMessage; if (exMessage != null && exMessage.toLowerCase().startsWith("datafile")) { outputMessage = exMessage; } else { outputMessage = "endpoint does not exist on this server. Please check your code for typos, or consult our API guide at http://guides.dataverse.org."; } return Response.status(404) .entity( Json.createObjectBuilder() .add("status", "ERROR") .add("code", 404) .add("message", "'" + uri + "' " + outputMessage) .build()) .type("application/json").build(); }
@Override public Response toResponse(final NotFoundException ex) { LOG.error("URL not found.", ex); final ErrorResponse errorResponse = new ErrorResponse.Builder()// .errorCode("BAD.URL.ERR")// .errorMessage(StringUtils.defaultString(ex.getMessage() + " Please make sure to use correct context. Please check the API document.", ex.toString()))// .build(); return Response.status(Response.Status.NOT_FOUND).entity(errorResponse).build(); }
LogMessages.LOGGER.error(Messages.MESSAGES.resourceNotFound(e.getMessage()), e);
public Response toResponse(NotFoundException e) { if (e.getMessage().contains("favicon.ico")) { try { Module module = Module.getBootModuleLoader().loadModule(ModuleIdentifier.create("org.wildfly.swarm.undertow", "runtime")); ClassLoader cl = module.getClassLoader(); final InputStream in = cl.getResourceAsStream("favicon.ico"); if (in != null) { Response.ResponseBuilder builder = Response.ok(); builder.entity( in ); return builder.build(); } } catch (ModuleLoadException e1) { throw e; } } // can't handle it, rethrow. throw e; } }
public Response toResponse(NotFoundException e) { if (e.getMessage().contains("favicon.ico")) { try { Module module = Module.getBootModuleLoader().loadModule(ModuleIdentifier.create("org.wildfly.swarm.undertow", "runtime")); ClassLoader cl = module.getClassLoader(); final InputStream in = cl.getResourceAsStream("favicon.ico"); if (in != null) { Response.ResponseBuilder builder = Response.ok(); builder.entity(in); return builder.build(); } } catch (ModuleLoadException e1) { throw e; } } // can't handle it, rethrow. throw e; } }
public ErrorResponse handleNotFoundError(HttpServletRequest req, NotFoundException exception) { List<Error> errors = Lists.newArrayList(); errors.add(new Error(String.valueOf(exception.getCode()), exception.getMessage())); return new ErrorResponse(errors);
Log.e("ItemActivity", n.getMessage()); } catch (JSONException j) { Log.e("ItemActivity", j.getMessage());