Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unprocessable Entity: raised error message provides insufficient information #233

Open
dragon-dxw opened this issue Nov 3, 2021 · 0 comments

Comments

@dragon-dxw
Copy link

dragon-dxw commented Nov 3, 2021

Debugging an issue with locales, I found that the error message from Contentful::Management::UnprocessableEntity was giving me no information beyond a ValidationError and that there was no name, path or value associated with the issue.

I've monkeypatched the `handle_error function like this and it gives much better details: this might be of interest more widely and might be worth using in the library itself.

module Contentful
  module Management
    class UnprocessableEntity
      def handle_error(error)
        name = error["name"]
        path = error["path"]
        value = error["value"]
        message = error["message"]
        details = error["details"]
        "\t* Name: #{name} - Path: '#{path}' - Value: '#{value}'\n\t  #{message}: #{details}"
      end
    end
  end
end

(original:

class UnprocessableEntity < Error
)

Let me know if you'd like a pull request.
(todo: work out whether name/path/value ever have values, if message and details can be absent, customise error appropriately)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant