001/* 002 * Copyright 2012-2018 the original author or authors. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 017package org.springframework.boot.autoconfigure.web; 018 019import org.springframework.beans.factory.annotation.Value; 020 021/** 022 * Configuration properties for web error handling. 023 * 024 * @author Michael Stummvoll 025 * @author Stephane Nicoll 026 * @author Vedran Pavic 027 * @since 1.3.0 028 */ 029public class ErrorProperties { 030 031 /** 032 * Path of the error controller. 033 */ 034 @Value("${error.path:/error}") 035 private String path = "/error"; 036 037 /** 038 * Include the "exception" attribute. 039 */ 040 private boolean includeException; 041 042 /** 043 * When to include a "stacktrace" attribute. 044 */ 045 private IncludeStacktrace includeStacktrace = IncludeStacktrace.NEVER; 046 047 private final Whitelabel whitelabel = new Whitelabel(); 048 049 public String getPath() { 050 return this.path; 051 } 052 053 public void setPath(String path) { 054 this.path = path; 055 } 056 057 public boolean isIncludeException() { 058 return this.includeException; 059 } 060 061 public void setIncludeException(boolean includeException) { 062 this.includeException = includeException; 063 } 064 065 public IncludeStacktrace getIncludeStacktrace() { 066 return this.includeStacktrace; 067 } 068 069 public void setIncludeStacktrace(IncludeStacktrace includeStacktrace) { 070 this.includeStacktrace = includeStacktrace; 071 } 072 073 public Whitelabel getWhitelabel() { 074 return this.whitelabel; 075 } 076 077 /** 078 * Include Stacktrace attribute options. 079 */ 080 public enum IncludeStacktrace { 081 082 /** 083 * Never add stacktrace information. 084 */ 085 NEVER, 086 087 /** 088 * Always add stacktrace information. 089 */ 090 ALWAYS, 091 092 /** 093 * Add stacktrace information when the "trace" request parameter is "true". 094 */ 095 ON_TRACE_PARAM 096 097 } 098 099 public static class Whitelabel { 100 101 /** 102 * Whether to enable the default error page displayed in browsers in case of a 103 * server error. 104 */ 105 private boolean enabled = true; 106 107 public boolean isEnabled() { 108 return this.enabled; 109 } 110 111 public void setEnabled(boolean enabled) { 112 this.enabled = enabled; 113 } 114 115 } 116 117}