Skip to content

refactor files controller error handling #2266

@johrstrom

Description

@johrstrom

I think we are going to move forward with #2251 - at least for the moment. I believe for this scheme to fit a little nicer we'd likely have to make error partials that I believe (assume really) that Rails will just take care of choosing which one (json or html) based on the request.format.

So we'd potentially end up with something like this.

  rescue_from AllowlistPolicy::Forbidden, with: :not_allowed_error

  def not_allowed_error(error)
    respond_to_error(status: :forbidden, error: error)
  end

  def respond_to_error(status: :internal_server_error, error: nil)
    logger.error(error.message) unless error.nil?

    @files = []
    @error = error
    render error, status: status
  end

Again - I just think this is the case, I haven't put more work into it beyond investigating.

Originally posted by johrstrom in #2258 (comment)

Metadata

Metadata

Assignees

Type

No type

Projects

Status

Reviewed, Scheduled

Relationships

None yet

Development

No branches or pull requests

Issue actions