Rust panics when I look for an incorrect id
See original GitHub issueDeno 1.2.0
TypeScript 3.9.6
MongoDriver 0.9.2
When I try to use findOne() method for searching an incorrect / inexistent ID rust panics and the server crashes. I also try to catch the error, but nothing changes. Is there a way to avoid this tedious problem?
    async show ( ctx : any ) {
        try{
        const data = await user.findOne(
            {_id: {$oid: ctx.params.id}},
            );
             ctx.response.body = data;
        } catch (e) {
            ctx.response.status = 404;
            ctx.response.body = {error: "This isn't the user you're looking for"};
        }
    },
thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: FromHexError(OddLength)', /Users/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/bson-0.14.1/src/bson.rs:575:39
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:8 (1 by maintainers)
 Top Results From Across the Web
Top Results From Across the Web
Rust Panic when querying a model with @@id #1729 - GitHub
Rust Panic when querying a model with @@id #1729 ... I see this error: PANIC: ... error which probably happens when the Prisma...
Read more >How do I write a Rust unit test that ensures that a panic has ...
You can find the answer in testing section of the Rust book. More specifically, you want #[should_panic] attribute:
Read more >Unrecoverable Errors with panic! - The Rust Programming ...
By default, when a panic occurs, the program starts unwinding, which means Rust walks back up the stack and cleans up the data...
Read more >How to catch panics in test code so that I can clean up ... - Reddit
I am using the built in actix_web::test module to build an App, send a request and then check out the result. I get...
Read more >1236-stabilize-catch-panic - The Rust RFC Book
It is currently defined as undefined behavior to have a Rust program panic across an FFI boundary. For example if C calls into...
Read more > Top Related Medium Post
Top Related Medium Post
No results found
 Top Related StackOverflow Question
Top Related StackOverflow Question
No results found
 Troubleshoot Live Code
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free Top Related Reddit Thread
Top Related Reddit Thread
No results found
 Top Related Hackernoon Post
Top Related Hackernoon Post
No results found
 Top Related Tweet
Top Related Tweet
No results found
 Top Related Dev.to Post
Top Related Dev.to Post
No results found
 Top Related Hashnode Post
Top Related Hashnode Post
No results found

Ah, yes, you need to import ObjectId from deno_mongo
import { ObjectId } from 'https://deno.land/x/mongo@v0.9.1/mod.ts';This problem should no longer exist