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.

support throwing an error on an unsuccessful getParams, getFormData instead of allowing `.data` being undefined

See original GitHub issue

Describe the bug

Often I use getParams like so. I wish getParams just throw an exception on unsuccessful parse instead of me having to check for it everytime

const parsedFormData = await getParams(formData, someSchema)

// I wish I didn't have to do this every time
if (!parsedFormData.data) throw new Error("no data")

// do something with
parsedFormData.data.someField

Your Example Website or App

every app

Steps to Reproduce the Bug or Issue

as listed

Expected behavior

throwing an exception

Screenshots or Videos

No response

Platform

server

Additional context

No response

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
kilimancommented, Feb 16, 2022

We’ve already used getParams for safe parsing. Also, I think that’s the better default. I’m adding the *OrFail() versions. This will be pushed out shortly.

0reactions
kilimancommented, Feb 16, 2022

Closed by 30ab3a1cff39a6d396416a657bb3a0b8c16d7adb

Read more comments on GitHub >

github_iconTop Results From Across the Web

Next.js keeps throwing error params is undefined
To access id in nextjs. I imported useRouter from next/router. Then I const router = useRouter(). Then const {id} = router.query.
Read more >
useQuery & undefined data · Discussion #1331 · TanStack/query
Hi, I've been using react-query for some time now, and so far enjoying it. However, one thing that I find odd is data...
Read more >
Solved: "Undefined" Error Upon Form Submission
I cannot reproduce the error using the Same PDF / Data. 3. They have submitted PDF's before (they have contribute level permissions). I...
Read more >
Web on Servlet Stack - Spring
The DispatcherServlet , as any Servlet , needs to be declared and mapped according to the Servlet specification by using Java configuration or...
Read more >
Intrgormat integration results in The operation failed with an ...
I am trying to use Integromat with my Jotform and it does collect the data but fails trying during the MS Word Template...
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