sailscastshq/boring-stack

Error Response don't work

Closed this issue · 15 comments

Hello,

When i try to do this in action 2:

sails.inertia.share('errors', {
        password: errorMessage
      })
      throw { badCombo: 'back' }

In the front "Vuejs", the inertia's form trigger onSuccess evenement 😢

form.post('/login',{
    onSuccess:()=>{
      console.log('success:',form.errors)
    },
    onError:()=>{
      console.log('error:',form.errors)
    }
  })

And form.errors has no keys....

Thanks for this, @DjCodeGit in the latest version of the Mellow template I think I fixed this for errors. You can look at the code in the signup and login actions

Hello @DominusKelvin , thanks for your answer. Unfortunately I had already tested the Mellow template and I got this error in case of user not found.
image

Great find can you create an issue please? Also does signing up a new user fix the error?

Why add new issue? This is the same problem for me. I would like to manage the backend's Error and send it to the front-end using "onError()" method of the Inertia's form.

Oh got it I thought it was a new error gotten from a user not being found.

I'm working on error handling for a patch release of mellow-vue which will also close this issue.

I'll let you know as soon as I make that fix

Hey @DjCodeGit I have been able to reproduce and I'll cut a new patch with these changes soon.

CleanShot 2023-09-29 at 14 41 55@2x

Hey @DjCodeGit were you able to move forward with this? I have been caught up with other things and I haven't add time to put in the error checks.

Hi Kelvin, did you manage to fix the error handling mellow-vue?

Hey @davidtwin, error handling exists today, I just haven't added an example in the template. What sort of errors do you want to handle? Maybe I can point you in the right direction.

Hey @DominusKelvin
When i write this on my controller

sails.inertia.share('errors', {
email: credentialErrorMessage
})

nothing i getting saved onto errors.

on your pingcrm example it saves on to it but not on this template

Hey @davidtwin and @DjCodeGit this #80 resolves this and I will update the docs on how to send server side validation errors to your SPA via props.

The new release fixes this issue @DjCodeGit :)

#83

Thanks you Kelvin. I'll test it as soon as possible.Le 22 févr. 2024 09:54, Kelvin Oghenerhoro Omereshone @.***> a écrit :

The new release fixes this issue @DjCodeGit :)

#83

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you were mentioned.Message ID: @.***>

Awesome thanks for your patience on this one. I needed a missing piece to really have the best DX for server side validation errors - Sails Flash

When you upgrade just instal sails-flash in your project as well upgrade inertia-sails

I'll write you release article on The Sailscasts Blog soon