Skip to content

Commit

Permalink
[webui] Fix errbit error: Package::UnknownObjectError: home:TEggers/p…
Browse files Browse the repository at this point in the history
…atchinfo

With this patch we catch UnknownObjectErrors and show an error message in
the ui, instead of failing with a 500.

http://errbit-opensuse.herokuapp.com/apps/5620ca2bdc71fa00b1000000/problems/57220b6d66cb310006000000
  • Loading branch information
bgeuken committed Apr 29, 2016
1 parent 3237159 commit 7911f8d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/api/app/controllers/webui/package_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1079,7 +1079,7 @@ def require_package

unless @package
flash[:error] = "Package \"#{params[:package]}\" not found in project \"#{params[:project]}\""
redirect_to controller: :project, action: :show, project: @project, nextstatus: 404
redirect_to project_show_path(project: @project, nextstatus: 404)
end
end

Expand Down
8 changes: 7 additions & 1 deletion src/api/app/controllers/webui/patchinfo_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,13 @@ def get_binaries

def require_exists
unless params[:package].blank?
@package = Package.get_by_project_and_name(params[:project], params[:package], use_source: false)
begin
@package = Package.get_by_project_and_name(params[:project], params[:package], use_source: false)
rescue Package::UnknownObjectError
flash[:error] = "Patchinfo '#{params[:package]}' not found in project '#{params[:project]}'"
redirect_to project_show_path(project: params[:project])
return
end
end

unless @package && @package.patchinfo
Expand Down

0 comments on commit 7911f8d

Please sign in to comment.