question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can't catch errors of path params

See original GitHub issue

When I do http://localhost:8080/my/dassda , I want to see a bad request, but I get I received 0. Revision I use is be025c92. Is there a way to handle bad params?

@Path("{iii}")
data class MyParam(@PathParam("I'm int") val iii: Int)

route("my") {
    throws(
        status = HttpStatusCode.BadRequest,
        example = "bad request",
        exClass = Throwable::class
    ) {
        get<MyParam, String> { param ->
            respond("I received ${param.iii}")
        }
    }
}

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
Wicparcommented, Apr 7, 2020
0reactions
Wicparcommented, Apr 7, 2020

You can replace the primitive default values with a ParsingError throw in https://github.com/papsign/Ktor-OpenAPI-Generator/blob/reworked-model/src/main/kotlin/com/papsign/ktor/openapigen/parameters/parsers/converters/primitive/PrimitiveConverter.kt I can’t work on it today as i am on a consulting mission.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Can't catch the URL parameters with ExpressJS - Stack Overflow
if you want the catch the value in the url means use req.query instead of req.params pass the value using the key of...
Read more >
Path Parameters - FastAPI
You can declare path "parameters" or "variables" with the same syntax used by Python format strings: from fastapi import FastAPI app = FastAPI() ......
Read more >
Error handling - Express.js
It's important to ensure that Express catches all errors that occur while running route handlers and middleware. Errors that occur in synchronous code ......
Read more >
Exceptions - Manual - PHP
(The variable was required prior to PHP 8.0.0.) The first catch block a thrown exception or error encounters that matches the type of...
Read more >
Error Handling | tsoa - GitHub Pages
Handling missing routes #. In order to handle missing urls more gracefully, we can add a "catch-all" route handler: ts
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found