title: @ControllerAvice Exception Handler does not work Internal Server Error
body: <p>I'm implementing a global Exception Handler with 
  <strong><em>Spring Boot</em></strong> @ControllerAdivce 
  <strong><em>in Kotlin</em></strong> with <strong><em>Gradle</em></strong></p>
  
  <pre><code>class SensorTypeNotFoundException(message: String) : RuntimeException(message)
  </code></pre>
  
  <p>if I <em>throw SensorTypeNotFoundException</em>, I have 500 Internal Server Error</p>
  
  <p>I can't understand why Spring Boot doesn't see my ExceptionController.</p>
  
  <p>Can anyone help please?</p>
  
  <p>This is my CustomExceptionController: </p>
  
  <pre><code>@ControllerAdvice
  @RestController
  class CustomExceptionController {
  
      private val logger = LoggerFactory.getLogger(javaClass.name)
  
      enum class ErrorKeys {
          ***
      }
  
      @ExceptionHandler(Exception::class)
      fun handleException(exception: Exception): ResponseEntity&lt;ExceptionResponse&gt; {
          ***
      }
  
      private fun createExceptionResponseEntity(exception: Exception): ResponseEntity&lt;ExceptionResponse&gt; {
          ***
          }
      }
  
      private fun buildResponse(message: String?, errorKey: ErrorKeys, httpStatus: HttpStatus): ResponseEntity&lt;ExceptionResponse&gt; {
          ***
          )
  
          return ResponseEntity(responseEntity, responseEntity.status)
      }
  }
  </code></pre>
  
  <p>build.gradle.kts:</p>
  
  <pre><code>
  ...
  plugins {
      id("org.springframework.boot") version "2.1.6.RELEASE"
      id("io.spring.dependency-management") version "1.0.7.RELEASE"
      kotlin("jvm") version "1.2.71"
      kotlin("plugin.spring") version "1.2.71"
  }
  ...
  dependencies {
      implementation("org.springframework.boot:spring-boot-starter-data-mongodb")
      implementation("org.springframework.boot:spring-boot-starter-webflux")
      implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
      implementation("org.jetbrains.kotlin:kotlin-reflect")
      implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
      developmentOnly("org.springframework.boot:spring-boot-devtools")
      testImplementation("org.springframework.boot:spring-boot-starter-test")
      testImplementation("io.projectreactor:reactor-test")
  }
  ...
  </code></pre>