module ViewModel::Controller

def render_error(error_view, status = 500)

def render_error(error_view, status = 500)
  unless error_view.is_a?(ViewModel)
    raise "Expected ViewModel error view, received #{error_view.inspect}"
  end
  render_jbuilder(status: status) do |json|
    json.error do
      ctx = error_view.class.new_serialize_context(access_control: ViewModel::AccessControl::Open.new)
      ViewModel.serialize(error_view, json, serialize_context: ctx)
    end
  end
end