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

refs #36243 - Templates - Return Foreman's API status code #869

Merged
merged 1 commit into from
May 22, 2023

Conversation

stejskalleos
Copy link
Contributor

Bugfixes and improvements

refs 70073c0

@Ron-Lavi
Copy link
Member

@ekohl could you take a look at this one? it should address your concerns about the previous PR

@Ron-Lavi
Copy link
Member

Hey @ekohl, any thoughts about this one? thanks

Copy link
Member

@ekohl ekohl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apologies for not getting to this. I'm not sure I like the already too complex method.

Have you considered to call it as log_halt(e.status_code, e, msg). So taking one example:

get "/:kind/:template/:hostgroup" do |kind, template, hostgroup|
  log_halt(nil, "Failed to retrieve #{kind} hostgroup template for #{params.inspect}: ") do
    Proxy::Templates::TemplateProxyRequest.new.get([kind, template, hostgroup], request.env, params)
  end
end

I wonder if you can rewrite it as:

get "/:kind/:template/:hostgroup" do |kind, template, hostgroup|
  Proxy::Templates::TemplateProxyRequest.new.get([kind, template, hostgroup], request.env, params)
rescue StandardError => e
  log_halt(e.status_code, e, "Failed to retrieve #{kind} hostgroup template for #{params.inspect}: ")
end

Given we're branching tomorrow I'm going merge it since it at least makes the code safer.

@ekohl ekohl merged commit 31778c3 into theforeman:develop May 22, 2023
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants