Here are the examples of the java api org.springframework.http.HttpStatus.INTERNAL_SERVER_ERROR taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
788 Examples
19
Source : WebExceptionHandler.java
with MIT License
from zhaojun1998
with MIT License
from zhaojun1998
private String generateErrorInfo(int code, String msg) {
return generateErrorInfo(code, msg, HttpStatus.INTERNAL_SERVER_ERROR.value());
}
19
Source : ResponseEntityPro.java
with Apache License 2.0
from yujunhao8831
with Apache License 2.0
from yujunhao8831
public static ResponseEnreplacedy<String> internalServerError() {
return status(HttpStatus.INTERNAL_SERVER_ERROR, HttpStatus.INTERNAL_SERVER_ERROR.getReasonPhrase());
}
19
Source : ResponseEntityPro.java
with Apache License 2.0
from yujunhao8831
with Apache License 2.0
from yujunhao8831
public static <T> ResponseEnreplacedy<T> internalServerError(final T body, final String filterFields) {
if (null == filterFields || WILDCARD_ALL.equals(filterFields)) {
return internalServerError(body);
}
return status(HttpStatus.INTERNAL_SERVER_ERROR, body, filterFields);
}
19
Source : ResponseEntityPro.java
with Apache License 2.0
from yujunhao8831
with Apache License 2.0
from yujunhao8831
public static <T> ResponseEnreplacedy<T> internalServerError(final T body) {
return status(HttpStatus.INTERNAL_SERVER_ERROR, body);
}
19
Source : DelayedLiveReloadTriggerTests.java
with Apache License 2.0
from yuanmabiji
with Apache License 2.0
from yuanmabiji
@Before
public void setup() throws IOException {
MockitoAnnotations.initMocks(this);
given(this.errorRequest.execute()).willReturn(this.errorResponse);
given(this.okRequest.execute()).willReturn(this.okResponse);
given(this.errorResponse.getStatusCode()).willReturn(HttpStatus.INTERNAL_SERVER_ERROR);
given(this.okResponse.getStatusCode()).willReturn(HttpStatus.OK);
this.trigger = new DelayedLiveReloadTrigger(this.liveReloadServer, this.requestFactory, URL);
}
19
Source : DefaultErrorAttributes.java
with Apache License 2.0
from yuanmabiji
with Apache License 2.0
from yuanmabiji
private HttpStatus determineHttpStatus(Throwable error) {
if (error instanceof ResponseStatusException) {
return ((ResponseStatusException) error).getStatus();
}
ResponseStatus responseStatus = AnnotatedElementUtils.findMergedAnnotation(error.getClreplaced(), ResponseStatus.clreplaced);
if (responseStatus != null) {
return responseStatus.code();
}
return HttpStatus.INTERNAL_SERVER_ERROR;
}
19
Source : FileUploadController.java
with MIT License
from wu-boy
with MIT License
from wu-boy
@ApiOperation("删除文件")
@DeleteMapping("delete/{filename}")
public BaseResult delete(@PathVariable String filename) {
BaseResult result = new BaseResult();
try {
File file = new File(FILE_PATH + filename);
file.delete();
result.setData(1);
result.setMessage("删除成功");
} catch (Exception e) {
result.setCode(HttpStatus.INTERNAL_SERVER_ERROR.value());
result.setMessage("上传文件错误");
e.printStackTrace();
}
return result;
}
19
Source : ControllerAdvice.java
with MIT License
from woowacourse-teams
with MIT License
from woowacourse-teams
@ExceptionHandler(Exception.clreplaced)
public ResponseEnreplacedy<ErrorResponse> unHandledExceptionHandler(Exception exception) {
ErrorResponse errorResponse = new ErrorResponse(exception.getMessage());
log.error("Exception : {}", exception.getMessage());
return ResponseEnreplacedy.status(HttpStatus.INTERNAL_SERVER_ERROR).body(errorResponse);
}
19
Source : HesperidesScenario.java
with GNU General Public License v3.0
from voyages-sncf-technologies
with GNU General Public License v3.0
from voyages-sncf-technologies
protected void replacedertInternalServerError() {
replacedertEquals(HttpStatus.INTERNAL_SERVER_ERROR, testContext.getResponseStatusCode());
}
19
Source : StatusResultMatchers.java
with MIT License
from Vip-Augus
with MIT License
from Vip-Augus
/**
* replacedert the response status code is {@code HttpStatus.INTERNAL_SERVER_ERROR} (500).
*/
public ResultMatcher isInternalServerError() {
return matcher(HttpStatus.INTERNAL_SERVER_ERROR);
}
19
Source : OrderController.java
with Apache License 2.0
from teixeira-fernando
with Apache License 2.0
from teixeira-fernando
/**
* Creates a new order.
*
* @param order The order to create.
* @return The created order.
*/
@PostMapping("/order")
@ApiResponses(value = { @ApiResponse(code = 200, message = "Expected order to a valid request", response = Product.clreplaced), @ApiResponse(code = 400, message = "There is a problem with the request parameters", response = Error.clreplaced), @ApiResponse(code = 500, message = "unexpected server error", response = Error.clreplaced) })
public ResponseEnreplacedy<Order> createOrder(@RequestBody OrderDto orderDto) {
logger.info("Creating new order");
try {
// Create the new order
Order newOrder = orderService.createOrder(orderDto);
// Build a created response
return ResponseEnreplacedy.created(new URI("/order/" + newOrder.getId())).body(newOrder);
} catch (InvalidParameterException e) {
return new ResponseEnreplacedy("A product included in the Order was not found in the inventory or there is not enough stock", HttpStatus.BAD_REQUEST);
} catch (EmptyOrderException e) {
return new ResponseEnreplacedy("The order does not contain any product", HttpStatus.BAD_REQUEST);
} catch (StockUpdateException e) {
return new ResponseEnreplacedy("Something went wrong when trying to communicate with the inventory service", HttpStatus.SERVICE_UNAVAILABLE);
} catch (URISyntaxException e) {
return ResponseEnreplacedy.status(HttpStatus.INTERNAL_SERVER_ERROR).build();
}
}
19
Source : DefaultApiResultTransformer.java
with Apache License 2.0
from spring-avengers
with Apache License 2.0
from spring-avengers
public ApiResult handleException(HttpServletRequest request, Exception ex) {
return ApiResult.builder().time(System.currentTimeMillis()).success(false).code(String.valueOf(HttpStatus.INTERNAL_SERVER_ERROR.value())).data(null).error(ex.getClreplaced().getName()).message(ex.getMessage()).path(request.getRequestURI()).build();
}
19
Source : StatusAssertionTests.java
with Apache License 2.0
from SourceHot
with Apache License 2.0
from SourceHot
@Test
public void statusSerius5xx() {
Statusreplacedertions replacedertions = statusreplacedertions(HttpStatus.INTERNAL_SERVER_ERROR);
// Success
replacedertions.is5xxServerError();
// Wrong series
replacedertThatExceptionOfType(replacedertionError.clreplaced).isThrownBy(() -> replacedertions.is2xxSuccessful());
}
19
Source : HeraExceptionHandler.java
with GNU General Public License v2.0
from scxwhite
with GNU General Public License v2.0
from scxwhite
@ExceptionHandler(Exception.clreplaced)
public Object handlerException(HttpServletRequest request, Exception ex) {
ErrorLog.error("请求" + request.getRequestURI() + "异常:", ex);
return getReturn(getReturnType(request), HttpStatus.INTERNAL_SERVER_ERROR, "请求异常,请联系管理员", "当您看到这个页面,表示该应用出错,请联系管理员进行解决");
}
19
Source : Message.java
with Apache License 2.0
from Saseke
with Apache License 2.0
from Saseke
/**
* 普通返回错误的数据
*/
public static Message failed() {
/*
* return new Message(HttpStatus.INTERNAL_SERVER_ERROR.value(),
* HttpStatus.INTERNAL_SERVER_ERROR.getReasonPhrase(), null);
*/
return failed(HttpStatus.INTERNAL_SERVER_ERROR.getReasonPhrase());
}
19
Source : XsuaaRequestDispatcher.java
with Apache License 2.0
from SAP
with Apache License 2.0
from SAP
protected MockResponse getInternalErrorResponse(String message) {
logger.warn(message);
return getResponse(RESPONSE_500 + ": " + message, HttpStatus.INTERNAL_SERVER_ERROR);
}
19
Source : ZuulFallbackProviderConfig.java
with GNU Affero General Public License v3.0
from romeoblog
with GNU Affero General Public License v3.0
from romeoblog
public ClientHttpResponse fallbackResponse() {
return this.response(HttpStatus.INTERNAL_SERVER_ERROR);
}
19
Source : CountryLanguageAPIController.java
with MIT License
from PacktPublishing
with MIT License
from PacktPublishing
@GetMapping("/{countryCode}")
public ResponseEnreplacedy<?> getLanguages(@PathVariable String countryCode, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo) {
try {
return ResponseEnreplacedy.ok(cLanguageDao.getLanguages(countryCode, pageNo));
} catch (Exception ex) {
System.out.println("Error while getting languages for country: {}" + countryCode + ex);
return ResponseEnreplacedy.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Error while languages cities");
}
}
19
Source : CountryAPIController.java
with MIT License
from PacktPublishing
with MIT License
from PacktPublishing
@GetMapping("/{countryCode}/gdp")
public ResponseEnreplacedy<?> getGDP(@PathVariable String countryCode) {
try {
return ResponseEnreplacedy.ok(worldBankApiClient.getGDP(countryCode));
} catch (Exception ex) {
System.out.println("Error while getting GDP for country: {}" + countryCode + ex);
return ResponseEnreplacedy.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Error while getting the GDP");
}
}
19
Source : ConfigEndpoint.java
with Apache License 2.0
from Nepxion
with Apache License 2.0
from Nepxion
protected ResponseEnreplacedy<String> toExceptionResponseEnreplacedy(Exception e, boolean showDetail) {
String message = null;
if (showDetail) {
message = ExceptionUtils.getStackTrace(e);
} else {
message = e.getMessage();
}
message = "An internal error occurred while processing your request\n" + message;
return ResponseEnreplacedy.status(HttpStatus.INTERNAL_SERVER_ERROR).body(message);
}
19
Source : AbstractRestInvoker.java
with Apache License 2.0
from Nepxion
with Apache License 2.0
from Nepxion
public ResponseEnreplacedy<?> invoke() {
if (CollectionUtils.isEmpty(instances)) {
LOG.warn("No service instances found");
return ResponseEnreplacedy.status(HttpStatus.INTERNAL_SERVER_ERROR).body("No service instances found");
}
List<ResultEnreplacedy> resultEnreplacedyList = new ArrayList<ResultEnreplacedy>();
for (ServiceInstance instance : instances) {
Map<String, String> metadata = instance.getMetadata();
String host = instance.getHost();
int port = instance.getPort();
String contextPath = metadata.get(DiscoveryMetaDataConstant.SPRING_APPLICATION_CONTEXT_PATH);
if (StringUtils.isEmpty(contextPath)) {
contextPath = "/";
}
String url = "http://" + host + ":" + port + UrlUtil.formatContextPath(contextPath) + getSuffixPath();
String result = null;
try {
checkPermission(instance);
result = doRest(url);
if (!StringUtils.equals(result, DiscoveryConstant.OK)) {
result = RestUtil.getCause(restTemplate);
}
} catch (Exception e) {
result = e.getMessage();
}
ResultEnreplacedy resultEnreplacedy = new ResultEnreplacedy();
resultEnreplacedy.setUrl(url);
resultEnreplacedy.setResult(result);
resultEnreplacedyList.add(resultEnreplacedy);
}
String info = getInfo();
LOG.info(info + " results=\n{}", resultEnreplacedyList);
return ResponseEnreplacedy.ok().body(resultEnreplacedyList);
}
19
Source : ExceptionHandlerController.java
with Apache License 2.0
from matthewgallina
with Apache License 2.0
from matthewgallina
@ExceptionHandler(MockServerException.clreplaced)
public ResponseEnreplacedy<String> handleMockServerException(MockServerException ex) {
logger.error(ex.getMessage());
return ResponseEnreplacedy.status(HttpStatus.INTERNAL_SERVER_ERROR).contentType(MediaType.APPLICATION_JSON).build();
}
19
Source : BambooServiceTest.java
with MIT License
from ls1intum
with MIT License
from ls1intum
@Test
@WithMockUser(username = "student1")
public void testHealthException() throws URISyntaxException, JsonProcessingException {
bambooRequestMockProvider.mockHealth("PAUSED", HttpStatus.INTERNAL_SERVER_ERROR);
var health = continuousIntegrationService.health();
replacedertThat(health.getAdditionalInfo().get("url")).isEqualTo(bambooServerUrl);
replacedertThat(health.isUp()).isEqualTo(false);
replacedertThat(health.getException()).isNotNull();
}
19
Source : CustomExceptionHandler.java
with Apache License 2.0
from LiuKay
with Apache License 2.0
from LiuKay
@ExceptionHandler({ Exception.clreplaced })
public ResponseEnreplacedy<ApiErrorResponse> handleException(Exception exception) {
return createErrorResponse(exception, HttpStatus.INTERNAL_SERVER_ERROR);
}
19
Source : R.java
with GNU General Public License v3.0
from LiHaodong888
with GNU General Public License v3.0
from LiHaodong888
public static R error(String msg) {
return error(HttpStatus.INTERNAL_SERVER_ERROR.value(), msg);
}
19
Source : R.java
with GNU General Public License v3.0
from LiHaodong888
with GNU General Public License v3.0
from LiHaodong888
public static R error() {
return error(HttpStatus.INTERNAL_SERVER_ERROR.value(), "未知异常,请联系管理员");
}
19
Source : BaseGlobalExceptionHandler.java
with Apache License 2.0
from lerry903
with Apache License 2.0
from lerry903
/**
* 处理运行时系统异常(反500错误码)
*/
protected DefaultErrorResult handleRuntimeException(RuntimeException e, HttpServletRequest request) {
log.error("handleRuntimeException start, uri:{}, caused by: ", request.getRequestURI(), e);
return DefaultErrorResult.failure(ResultCode.SYSTEM_INNER_ERROR, e, HttpStatus.INTERNAL_SERVER_ERROR);
}
19
Source : DecisionRestResourceSpringTemplate.java
with Apache License 2.0
from kiegroup
with Apache License 2.0
from kiegroup
private ResponseEnreplacedy buildFailedEvaluationResponse(KogitoDMNResult result) {
return ResponseEnreplacedy.status(HttpStatus.INTERNAL_SERVER_ERROR).body(result);
}
19
Source : ExceptionsHandlerTest.java
with Apache License 2.0
from kiegroup
with Apache License 2.0
from kiegroup
@Test
void tesreplacedernalError() {
ResponseEnreplacedy responseEnreplacedy = tested.internalError(body);
replacedertResponse(responseEnreplacedy, HttpStatus.INTERNAL_SERVER_ERROR);
}
19
Source : ResponseEntityExceptionHandlerEx.java
with GNU General Public License v3.0
from JuniperBot
with GNU General Public License v3.0
from JuniperBot
@ExceptionHandler(Exception.clreplaced)
public final ResponseEnreplacedy<ErrorDetailsDto> handleAllExceptions(Exception e) {
return errorResponse(e, HttpStatus.INTERNAL_SERVER_ERROR);
}
19
Source : ServiceResult.java
with MIT License
from InnovateUKGitHub
with MIT License
from InnovateUKGitHub
public static <T> HttpStatus findStatusCode(List<ServiceResult<T>> failures) {
List<Error> aggregateErrors = aggregate(failures).getFailure().getErrors();
return simpleFindFirst(aggregateErrors, error -> error.getStatusCode() != null).map(Error::getStatusCode).orElse(HttpStatus.INTERNAL_SERVER_ERROR);
}
19
Source : HelloController.java
with Apache License 2.0
from ibm-cloud-architecture
with Apache License 2.0
from ibm-cloud-architecture
@GetMapping("/error")
public ResponseEnreplacedy<String> replyError() {
return ResponseEnreplacedy.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
}
19
Source : BaseResponse.java
with BSD 3-Clause "New" or "Revised" License
from hxnlyw
with BSD 3-Clause "New" or "Revised" License
from hxnlyw
public static BaseResponse<Boolean> fail() {
return fail(HttpStatus.INTERNAL_SERVER_ERROR);
}
19
Source : BaseResponse.java
with BSD 3-Clause "New" or "Revised" License
from hxnlyw
with BSD 3-Clause "New" or "Revised" License
from hxnlyw
public static BaseResponse<String> fail(String message) {
return result(HttpStatus.INTERNAL_SERVER_ERROR, message, null);
}
19
Source : ResultVo.java
with Apache License 2.0
from hiparker
with Apache License 2.0
from hiparker
/**
* 返回错误状态
* @return ResultVo<Object>
*/
@JsonIgnore
public static ResultVo<Object> error() {
return ResultVo.error(HttpStatus.INTERNAL_SERVER_ERROR.value(), DEF_ERROR_MSG, null);
}
19
Source : ResultVo.java
with Apache License 2.0
from hiparker
with Apache License 2.0
from hiparker
/**
* 返回错误状态
* @param msg 返回信息
* @return ResultVo<Object>
*/
@JsonIgnore
public static ResultVo<Object> error(String msg) {
return ResultVo.error(HttpStatus.INTERNAL_SERVER_ERROR.value(), msg, null);
}
19
Source : DefaultErrorAttributes.java
with Apache License 2.0
from hello-shf
with Apache License 2.0
from hello-shf
private HttpStatus determineHttpStatus(Throwable error) {
if (error instanceof ResponseStatusException) {
return ((ResponseStatusException) error).getStatus();
}
return HttpStatus.INTERNAL_SERVER_ERROR;
}
19
Source : R.java
with GNU General Public License v3.0
from Gyv12345
with GNU General Public License v3.0
from Gyv12345
public static <T> R<T> failed(T result) {
return result(result, HttpStatus.INTERNAL_SERVER_ERROR.value(), null);
}
19
Source : R.java
with GNU General Public License v3.0
from Gyv12345
with GNU General Public License v3.0
from Gyv12345
public static <T> R<T> failed(T result, String message) {
return result(result, HttpStatus.INTERNAL_SERVER_ERROR.value(), message);
}
19
Source : R.java
with GNU General Public License v3.0
from Gyv12345
with GNU General Public License v3.0
from Gyv12345
public static <T> R<T> failed() {
return result(null, HttpStatus.INTERNAL_SERVER_ERROR.value(), null);
}
19
Source : R.java
with GNU General Public License v3.0
from Gyv12345
with GNU General Public License v3.0
from Gyv12345
public static <T> R<T> failed(String message) {
return result(null, HttpStatus.INTERNAL_SERVER_ERROR.value(), message);
}
19
Source : CustomizedExceptionHandler.java
with GNU Affero General Public License v3.0
from GIScience
with GNU Affero General Public License v3.0
from GIScience
@ExceptionHandler(DatabaseAccessException.clreplaced)
public final ResponseEnreplacedy<ErrorDetails> handleDatabaseAccessException(DatabaseAccessException ex, HttpServletRequest servletRequest) {
return createExceptionResponse(ex, HttpStatus.INTERNAL_SERVER_ERROR, servletRequest);
}
19
Source : FebsResponse.java
with Apache License 2.0
from febsteam
with Apache License 2.0
from febsteam
public FebsResponse fail() {
code(HttpStatus.INTERNAL_SERVER_ERROR);
return this;
}
19
Source : GlobalControllerExceptionHandlerTest.java
with MIT License
from FAForever
with MIT License
from FAForever
@Test
public void testProgrammingError() {
ProgrammingError ex = new ProgrammingError(COMMON_MESSAGE);
ErrorResponse response = instance.processProgrammingError(ex);
replacedertEquals(1, response.getErrors().size());
final ErrorResult errorResult = response.getErrors().get(0);
replacedertEquals(HttpStatus.INTERNAL_SERVER_ERROR.getReasonPhrase(), errorResult.getreplacedle());
replacedertEquals(COMMON_MESSAGE, errorResult.getDetail());
}
19
Source : RestApiExceptionTest.java
with Apache License 2.0
from eclipse
with Apache License 2.0
from eclipse
@Test
public void testRestApiExceptionWithMessage() {
RestApiException apiException = new RestApiException("message");
replacedert.replacedertEquals(apiException.getMessage(), "message");
replacedert.replacedertEquals(apiException.getAppErrorCode(), "FAILURE");
replacedert.replacedertEquals(apiException.getHttpStatusCode(), HttpStatus.INTERNAL_SERVER_ERROR);
}
19
Source : RestApiExceptionTest.java
with Apache License 2.0
from eclipse
with Apache License 2.0
from eclipse
@Test
public void testRestApiExceptionWithException() {
RuntimeException runtimeException = new RuntimeException("Runtime exception message");
RestApiException apiException = new RestApiException(runtimeException);
replacedert.replacedertEquals(apiException.getCause(), runtimeException);
replacedert.replacedertEquals(apiException.getMessage(), "java.lang.RuntimeException: Runtime exception message");
replacedert.replacedertEquals(apiException.getAppErrorCode(), "FAILURE");
replacedert.replacedertEquals(apiException.getHttpStatusCode(), HttpStatus.INTERNAL_SERVER_ERROR);
}
19
Source : RestApiExceptionTest.java
with Apache License 2.0
from eclipse
with Apache License 2.0
from eclipse
@Test
public void testRestApiExceptionWithMessageExceptionBooleans() {
RuntimeException runtimeException = new RuntimeException();
RestApiException apiException = new RestApiException("message", runtimeException, true, true);
replacedert.replacedertEquals(apiException.getCause(), runtimeException);
replacedert.replacedertEquals(apiException.getMessage(), "message");
replacedert.replacedertEquals(apiException.getAppErrorCode(), "FAILURE");
replacedert.replacedertEquals(apiException.getHttpStatusCode(), HttpStatus.INTERNAL_SERVER_ERROR);
}
19
Source : RestApiExceptionTest.java
with Apache License 2.0
from eclipse
with Apache License 2.0
from eclipse
@Test
public void testRestApiExceptionWithMessageException() {
RuntimeException runtimeException = new RuntimeException();
RestApiException apiException = new RestApiException("message", runtimeException);
replacedert.replacedertEquals(apiException.getCause(), runtimeException);
replacedert.replacedertEquals(apiException.getMessage(), "message");
replacedert.replacedertEquals(apiException.getAppErrorCode(), "FAILURE");
replacedert.replacedertEquals(apiException.getHttpStatusCode(), HttpStatus.INTERNAL_SERVER_ERROR);
}
19
Source : RestApiExceptionTest.java
with Apache License 2.0
from eclipse
with Apache License 2.0
from eclipse
@Test
public void testRestApiExceptionDefaultConstructor() {
RestApiException apiException = new RestApiException();
replacedert.replacedertEquals(apiException.getMessage(), null);
replacedert.replacedertEquals(apiException.getAppErrorCode(), "FAILURE");
replacedert.replacedertEquals(apiException.getHttpStatusCode(), HttpStatus.INTERNAL_SERVER_ERROR);
}
19
Source : DbConnectorService.java
with GNU General Public License v3.0
from coti-io
with GNU General Public License v3.0
from coti-io
public HttpStatus getHttpStatus(MultiDbInsertionStatus multiDbInsertionStatus) {
if (multiDbInsertionStatus == MultiDbInsertionStatus.SUCCESS) {
return HttpStatus.OK;
} else if (multiDbInsertionStatus == MultiDbInsertionStatus.FAILED) {
return HttpStatus.INTERNAL_SERVER_ERROR;
}
return HttpStatus.MULTI_STATUS;
}
See More Examples