Signup Error: [object Object] #617

Closed
opened 2019-07-21 05:09:38 +00:00 by CrunkLord420 · 4 comments
Member

Whenever there's a sign-up error for any reason, the user gets a "[object Object]" message, instead of an actual error.
image

Whenever there's a sign-up error for any reason, the user gets a "[object Object]" message, instead of an actual error. ![image](/attachments/3bd03c8f-b803-4814-8372-638ff4bbaab8)
106 KiB
Member

In Firefox 68, if I mess up the captcha, then I get {"error":"{\"captcha\":[\"Invalid CAPTCHA\"]}"}.

It looks like signUp in src/modules/user.js is getting into its catch block and errors is a string containing a JSON object, but it isn't trying to humanize it because it's not an object according to typeof.

error appears to be a string instead of an object here in api.service.js:

return response.json().then((error) => { throw new Error(error) })

And then there's this in pleroma's Pleroma.Web.TwitterAPI.TwitterAPI.register_user:

    # Captcha invalid
    if captcha_ok != :ok do
      {:error, error} = captcha_ok
      # I have no idea how this error handling works
      {:error, %{error: Jason.encode!(%{captcha: [error]})}}

I might be able to hack something together for this assuming that the error is always going to be a string in a similar format to the one above.

In Firefox 68, if I mess up the captcha, then I get `{"error":"{\"captcha\":[\"Invalid CAPTCHA\"]}"}`. It looks like `signUp` in src/modules/user.js is getting into its `catch` block and `errors` is a string containing a JSON object, but it isn't trying to humanize it because it's not an `object` according to `typeof`. `error` appears to be a `string` instead of an `object` here in api.service.js: ```javascript return response.json().then((error) => { throw new Error(error) }) ``` And then there's this in pleroma's `Pleroma.Web.TwitterAPI.TwitterAPI.register_user`: ```elixir # Captcha invalid if captcha_ok != :ok do {:error, error} = captcha_ok # I have no idea how this error handling works {:error, %{error: Jason.encode!(%{captcha: [error]})}} ``` I might be able to hack something together for this assuming that the error is always going to be a string in a similar format to the one above.
Owner

yeah, FE needs better error handling overall

yeah, FE needs better error handling overall
Author
Member

After the changes I now get no error message box whatsoever, and I get a JavaScript error in the console image

After the changes I now get no error message box whatsoever, and I get a JavaScript error in the console ![image](/attachments/7f8dbd4f-edb2-407e-8ba4-9596ce325bb2)
8.7 KiB

This displays a proper error message now

This displays a proper error message now
Sign in to join this conversation.
No milestone
No project
No assignees
4 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
pleroma/pleroma-fe#617
No description provided.