
com.formkiq.server.api.ErrorController Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of formkiq-server Show documentation
Show all versions of formkiq-server Show documentation
Server-side integration for the FormKiQ ios application
/*
* Copyright (C) 2016 FormKiQ Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.formkiq.server.api;
import static javax.servlet.http.HttpServletResponse.SC_INTERNAL_SERVER_ERROR;
import static javax.servlet.http.HttpServletResponse.SC_METHOD_NOT_ALLOWED;
import static javax.servlet.http.HttpServletResponse.SC_NOT_FOUND;
import javax.servlet.http.HttpServletResponse;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.formkiq.server.config.ApplicationConfig;
import io.swagger.annotations.ApiOperation;
/**
* HTML error status handler.
*
*/
@RestController
public class ErrorController {
/**
* Handle 404.
* @param response HttpServletResponse
* @return ApiStringResponse
*/
@ApiOperation(value = "error404", nickname = "error404", hidden = true)
@RequestMapping(ApplicationConfig.API_ERROR_404)
public ApiMessageResponse error404(final HttpServletResponse response) {
response.setStatus(SC_NOT_FOUND);
return new ApiMessageResponse("invalid request url");
}
/**
* Handle 405.
* @param e Exception
* @param response HttpServletResponse
* @return ApiStringResponse
*/
@ApiOperation(value = "error405", nickname = "error405", hidden = true)
@RequestMapping(ApplicationConfig.API_ERROR_405)
public ApiMessageResponse error405(final Exception e,
final HttpServletResponse response) {
response.setStatus(SC_METHOD_NOT_ALLOWED);
return new ApiMessageResponse("invalid method for url");
}
/**
* Handle 500.
* @param response HttpServletResponse
* @return ApiStringResponse
*/
@ApiOperation(value = "error500", nickname = "error500", hidden = true)
@RequestMapping(ApplicationConfig.API_ERROR_500)
public ApiMessageResponse error500(final HttpServletResponse response) {
response.setStatus(SC_INTERNAL_SERVER_ERROR);
return new ApiMessageResponse("unable to process request");
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy