title: How to serve HTTP 400 when missing Location parameters?
body: <p>Consider this simple <a href="https://ktor.io/" rel="nofollow noreferrer">ktor</a> server setup</p>
  
  <pre class="lang-kotlin prettyprint-override"><code>@Location("/user") data class User(val id: Long)
  
  fun Application.module(testing: Boolean = false) {
      install(Locations)
      routing {
          get&lt;User&gt; {
              call.respondText("User[id: ${id}]")
          }
      }
  }
  </code></pre>
  
  <p>Getting <code>/user?id=123</code> works fine resulting in <code>User [id 123]</code>.</p>
  
  <p>However getting <code>/user</code> yields <code>HTTP 404</code> but a <code>HTTP 400</code> make much more sense here.</p>
  
  <p>How can I</p>
  
  <ol>
  <li>Serve <code>400</code> instead of <code>404</code> in such case?</li>
  <li>Attach a custom
  error handler for missing query parameters so I can provide clients
  with information about what they got wrong?</li>
  </ol>
  
  <p>sidenote: I also filled <a href="https://github.com/ktorio/ktor/issues/1711" rel="nofollow noreferrer">an issue</a> in the ktor github repository for this.</p>
  
  <p>Thanks in advance!</p>