Skip to content
Snippets Groups Projects
Commit fde07c1f authored by Gyan Gupta's avatar Gyan Gupta Committed by Anusha Ranganathan
Browse files

Implement error page for S3 connection failure

parent b770d2c3
Branches
Tags
1 merge request!300Implement error page for S3 connection failure
class ApplicationController < ActionController::Base
rescue_from Seahorse::Client::NetworkingError, with: :handle_s3_networking_error
helper Openseadragon::OpenseadragonHelper
# Adds a few additional behaviors into the application controller
include Blacklight::Controller
......@@ -10,4 +11,14 @@ class ApplicationController < ActionController::Base
include Hyrax::ThemedLayoutController
with_themed_layout '1_column'
private
def handle_s3_networking_error(exception)
respond_to do |format|
format.html do
render 'errors/error_message', locals: { heading: "Connectivity Issue", description: t('hyrax.uploads.js_templates.options.messages.s3_server_error') }, status: :internal_server_error
end
format.json { render plain: 's3_server_error', status: 500 }
end
end
end
<%
heading = local_assigns[:heading] || t("rdms.errors.#{params[:action]}.heading")
description = local_assigns[:description] || t("rdms.errors.#{params[:action]}.description")
%>
<div class="rails-default-error-page">
<div class="dialog">
<div class="dialog-heading">
<h1 class="heading-title"><%= t("rdms.errors.#{params[:action]}.heading")%></h1>
<p class="heading-body"><%= t("rdms.errors.#{params[:action]}.description")%></p>
<h1 class="heading-title"><%= heading %></h1>
<p class="heading-body"><%= description %></p>
</div>
<p class="dialog-body"><%= t("rdms.errors.suggestion")%></p>
</div>
......
......@@ -151,12 +151,19 @@
maxFileSize: '<%= t(".options.messages.max_file_size") %>',
maxNumberOfFiles: '<%= t(".options.messages.max_number_of_files") %>',
minFileSize: '<%= t(".options.messages.min_file_size") %>',
s3ServerError: '<%= t("rdms.errors.uploads.s3_server_error") %>',
fileNotAllowed: '<%= t("rdms.errors.uploads.file_not_allowed") %>'
}});
}).on('fileuploadfail', function (e, data) {
file = data.files[0]
dfd = $.Deferred();
data.files.error = true;
file.error = '<%= t("rdms.errors.uploads.file_not_allowed") %>'
if (data.response().jqXHR.responseText == 's3_server_error') {
file.error = data.messages.s3ServerError
}
else{
file.error = data.messages.fileNotAllowed
}
dfd.rejectWith(this, [data]);
$('#with_files_submit').attr('disabled', 'disabled')
return dfd.promise();
......
......@@ -97,6 +97,7 @@ en:
length: "The modality title should be between 3-63 characters long. Consider using leading zeros (e.g. 003 instead of 3)"
uploads:
file_not_allowed: "This file name is restricted. Delete this file and upload again after changing the name"
s3_server_error: "Apologies for the inconvenience. At the moment, this feature is not accessible. This is due to an issue with the connectivity to our research data storage. Our team is diligently working on resolving this. Please try again later. Thank you for your understanding and patience."
simple_form:
hints:
defaults:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment