All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.yawp.commons.http.ErrorResponse Maven / Gradle / Ivy

There is a newer version: 2.08alpha
Show newest version
package io.yawp.commons.http;

import java.io.IOException;

import javax.servlet.http.HttpServletResponse;

public class ErrorResponse extends HttpResponse {

	private int httpStatus;
	private String text;

	public ErrorResponse(int httpStatus, String text) {
		this.httpStatus = httpStatus;
		this.text = text;
	}

	public ErrorResponse(int httpStatus) {
		this(httpStatus, null);
	}

	public int getHttpStatus() {
		return httpStatus;
	}

	@Override
	public String getText() {
		return text;
	}

	@Override
	public void execute(HttpServletResponse resp) throws IOException {
		resp.setStatus(httpStatus);
		if (text != null) {
			resp.getWriter().write(StatusObject.error(text).toJson());
		}
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy