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

Display our custom error pages instead of catching them all as a generic 404 #1624

Open
3 tasks
bess opened this issue Dec 1, 2023 · 3 comments · Fixed by #1958
Open
3 tasks

Display our custom error pages instead of catching them all as a generic 404 #1624

bess opened this issue Dec 1, 2023 · 3 comments · Fixed by #1958
Labels

Comments

@bess
Copy link
Contributor

bess commented Dec 1, 2023

Currently, the application can experience an error and not raise an exception. This is going to make it hard for us to track problems.

Code that is capturing the errors:

def rescue_aasm_error
yield
rescue AASM::InvalidTransition => error
message = error.message
if @work.errors.count > 0
message = @work.errors.to_a.join(", ")
end
message.chop! if message.last == "."
Honeybadger.notify("Invalid #{@work.current_transition}: #{error.message} errors: #{message}")
transition_error_message = "We apologize, the following errors were encountered: #{message}. Please contact the PDC Describe administrators for any assistance."
@errors = [transition_error_message]
if @work.persisted?
redirect_to edit_work_url(id: @work.id), notice: transition_error_message, params:
else
new_params = {}
new_params[:wizard] = wizard_mode? if wizard_mode?
new_params[:migrate] = migrating? if migrating?
@form_resource_decorator = FormResourceDecorator.new(@work, current_user)
redirect_to new_work_url(params: new_params), notice: transition_error_message, params: new_params
end
rescue StandardError => generic_error
if action_name == "create"
if @work.persisted?
Honeybadger.notify("Failed to create the new Dataset #{@work.id}: #{generic_error.message}")
@form_resource_decorator = FormResourceDecorator.new(@work, current_user)
redirect_to edit_work_url(id: @work.id), notice: "Failed to create the new Dataset #{@work.id}: #{generic_error.message}", params:
else
Honeybadger.notify("Failed to create a new Dataset #{@work.id}: #{generic_error.message}")
new_params = {}
new_params[:wizard] = wizard_mode? if wizard_mode?
new_params[:migrate] = migrating? if migrating?
@form_resource_decorator = FormResourceDecorator.new(@work, current_user)
redirect_to new_work_url(params: new_params), notice: "Failed to create a new Dataset: #{generic_error.message}", params: new_params
end
else
redirect_to root_url, notice: "We apologize, an error was encountered: #{generic_error.message}. Please contact the PDC Describe administrators."
end
end

How to disable error catching at the load balancer so our own error pages will be displayed: pulibrary/princeton_ansible#4258

Acceptance criteria

  • When an error is encountered loading a page, honeybadger gets the notification
  • If it is an actual 404, do not raise an exception
  • For either a 404 or a 5xx, display a PDC Describe branded error page with a helpful message
@bess
Copy link
Contributor Author

bess commented Oct 4, 2024

@jrgriffiniii I merged your PR and deployed it to staging, but we still aren't seeing the custom error pages. Don't we need to change something on the load balancer to make these show up? (There is a link in the ticket with some breadcrumbs.)

Screenshot 2024-10-04 at 3 15 25 PM

@jrgriffiniii
Copy link
Contributor

I have just successfully provisioned staging, I am going to proceed with provisioning for prod outside of business hours.

@jrgriffiniii
Copy link
Contributor

This should be deployed into the production environment for review.

@jrgriffiniii jrgriffiniii removed their assignment Dec 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants