skorphil / nextjs-form

Educational NextJs project to build a complex mobile-first form
https://www.chromatic.com/library?appId=65b2882ac1586a6b21cba0dd
MIT License
3 stars 0 forks source link

add formSubmition error handling to ui #68

Closed skorphil closed 4 months ago

skorphil commented 4 months ago

If submitting the form fails, it must be error toast explaining what is happened

skorphil commented 4 months ago

To implement this, the throwing an errors should be precise (try catch on specific logic block). Also should avoid nesting try...catch, because rethrowing error seems not optimal.

try {
  throw1
  throw2
  throw3
} catch () // will get 1,2 or 3

try {
  try {
    t1, t2, t3
} catch // will get 1,2 or 3 {
   throw 4
}
} catch // will get 4

https://github.com/skorphil/nextjs-form/assets/6762009/714dc4ff-96d9-4ffb-af73-d83c6dcac3fc