Adding prettier error handling page in the pipeline

This commit is contained in:
rockstardev
2020-02-01 01:40:50 -06:00
parent 88835b5b55
commit fe2eca4fda
7 changed files with 204 additions and 42 deletions

View File

@@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
namespace BTCPayServer.Controllers
{
[Route("[controller]/[action]")]
public class ErrorController : Controller
{
public IActionResult Handle(int? statusCode = null)
{
return View(statusCode);
}
}
}

View File

@@ -241,6 +241,10 @@ namespace BTCPayServer.Hosting
forwardingOptions.KnownProxies.Clear();
forwardingOptions.ForwardedHeaders = ForwardedHeaders.All;
app.UseForwardedHeaders(forwardingOptions);
app.UseStatusCodePagesWithReExecute("/Error/Handle", "?statusCode={0}");
app.UsePayServer();
app.UseRouting();
app.UseCors();
@@ -252,7 +256,6 @@ namespace BTCPayServer.Hosting
app.UseSession();
app.UseWebSockets();
app.UseStatusCodePages();
app.UseEndpoints(endpoints =>
{

View File

@@ -0,0 +1,19 @@
@using System.Net
@model int?
@{
ViewData["ErrorTitle"] = "Generic Error occurred";
if (Model.HasValue)
{
var httpCode = (HttpStatusCode)Model.Value;
ViewData["ErrorTitle"] = $"{(int)httpCode} - {httpCode.ToString()}";
}
}
<p class="lead-login">
Generic error occurred, HTTP Code: @Model
<br /><br />
Consult server log for more details.
<br /><br />
<a href="/">Navigate back to home</a>.
<br /><br /><br />
</p>

View File

@@ -0,0 +1,118 @@
@{
Layout = null;
}
@inject BTCPayServer.Services.BTCPayServerEnvironment env
<!DOCTYPE html>
<html lang="en">
<head>
<partial name="Header" />
<link href="~/main/fonts/Montserrat.css" rel="stylesheet">
<style>
.content-wrapper {
padding: 20px 0;
}
@@media screen and (min-width: 768px) {
.content-wrapper {
padding: 20px 0;
}
}
.col-head {
display: flex;
align-items: center;
flex-direction: column;
justify-content: center;
text-align: center;
}
@@media screen and (min-width: 768px) {
.col-head {
text-align: left;
flex-direction: row;
justify-content: start;
}
}
.head-logo {
height: 70px;
margin-bottom: 1rem;
}
@@media screen and (min-width: 768px) {
.head-logo {
height: 100px;
margin-bottom: 0;
margin-right: 50px;
}
}
.lead-title {
font-family: Montserrat;
font-style: normal;
font-weight: bold;
font-size: 24px;
line-height: 1.2;
/* or 150% */
letter-spacing: 0.1em;
}
@@media screen and (min-width: 768px) {
.lead-title {
font-size: 40px;
}
}
.lead-login {
font-family: Montserrat;
font-style: normal;
font-weight: normal;
font-size: 18px;
line-height: 33px;
/* or 183% */
letter-spacing: 0.1em;
}
.lead-h {
font-family: Montserrat;
font-style: normal;
margin-bottom: 30px;
font-weight: 600;
font-size: 14px;
line-height: 18px;
/* identical to box height, or 129% */
letter-spacing: 0.1em;
text-transform: uppercase;
}
</style>
</head>
<body>
<center>
<section class="content-wrapper">
<!-- Dummy navbar-brand, hackish way to keep test AssertNoError passing -->
<div class="navbar-brand" style="display:none;"></div>
<div class="container">
<div class="row">
<div class="col-12 col-head" style="justify-content:center;">
<a asp-controller="Home" asp-action="Index"><img src="~/img/btcpay-logo.svg" alt="BTCPay Server" class="head-logo" /></a>
<h1 class="lead-title text-uppercase">@ViewData["ErrorTitle"]</h1>
</div>
</div>
<div class="row">
<div class="col-12">
<hr class="primary ml-0" style="margin:20px auto;" />
@RenderBody()
</div>
</div>
<div class="row">
<div class="col-12">
<hr class="primary ml-0" style="margin:20px auto;" />
@await Html.PartialAsync("_BTCPaySupporters")
</div>
</div>
</div>
</section>
</center>
</body>
</html>

View File

@@ -0,0 +1,3 @@
@{
Layout = "_LayoutError";
}

View File

@@ -0,0 +1,41 @@
<h3 class="lead-h">BTCPayServer Supporters <a href="https://foundation.btcpayserver.org/" target="_blank"><span class="fa fa-question-circle-o" title="More information..."></span></a></h3>
<div class="figure">
<a href="https://twitter.com/sqcrypto" target="_blank">
<img src="~/img/squarecrypto.svg" alt="Sponsor Square Crypto" height="75" />
</a>
<div class="figure-caption text-center">
<a href="https://twitter.com/sqcrypto" class="text-muted small" target="_blank">Square Crypto</a>
</div>
</div>
<div class="figure ml-4">
<a href="https://www.dglab.com/en/" target="_blank">
<img src="~/img/dglab.svg" alt="Sponsor DG lab" height="75" />
</a>
<div class="figure-caption text-center">
<a href="https://www.dglab.com/en/" class="text-muted small" target="_blank">DG Lab</a>
</div>
</div>
<div class="figure ml-4">
<a href="https://acinq.co/" target="_blank">
<img src="~/img/acinq-logo.svg" alt="Sponsor ACINQ" height="75" />
</a>
<div class="figure-caption text-center">
<a href="https://acinq.co/" class="text-muted small" target="_blank">ACINQ</a>
</div>
</div>
<div class="figure ml-4">
<a href="https://lunanode.com/" target="_blank">
<img src="~/img/lunanode.svg" alt="Sponsor LunaNode" height="75" />
</a>
<div class="figure-caption text-center">
<a href="https://lunanode.com/" class="text-muted small" target="_blank">LunaNode</a>
</div>
</div>
<div class="figure ml-4">
<a href="https://walletofsatoshi.com/" target="_blank">
<img src="~/img/walletofsatoshi.svg" alt="Sponsor Wallet of Satoshi" height="75" />
</a>
<div class="figure-caption text-center">
<a href="https://walletofsatoshi.com/" class="text-muted small" target="_blank">Wallet of Satoshi</a>
</div>
</div>

View File

@@ -102,47 +102,7 @@
<div class="col-md-7 order-md-1 order-2">
<hr class="primary ml-0" style="margin:30px auto;">
<p class="lead-login" style="margin-bottom:69px;">BTCPay Server is a self-hosted, open-source cryptocurrency payment processor. It is secure, private, censorship-resistant and free.</p>
<h3 class="lead-h">Our supporters <a href="https://foundation.btcpayserver.org/" target="_blank"><span class="fa fa-question-circle-o" title="More information..."></span></a></h3>
<div class="figure">
<a href="https://twitter.com/sqcrypto" target="_blank">
<img src="~/img/squarecrypto.svg" alt="Sponsor Square Crypto" height="75" />
</a>
<div class="figure-caption text-center">
<a href="https://twitter.com/sqcrypto" class="text-muted small" target="_blank">Square Crypto</a>
</div>
</div>
<div class="figure ml-4">
<a href="https://www.dglab.com/en/" target="_blank">
<img src="~/img/dglab.svg" alt="Sponsor DG lab" height="75" />
</a>
<div class="figure-caption text-center">
<a href="https://www.dglab.com/en/" class="text-muted small" target="_blank">DG Lab</a>
</div>
</div>
<div class="figure ml-4">
<a href="https://acinq.co/" target="_blank">
<img src="~/img/acinq-logo.svg" alt="Sponsor ACINQ" height="75" />
</a>
<div class="figure-caption text-center">
<a href="https://acinq.co/" class="text-muted small" target="_blank">ACINQ</a>
</div>
</div>
<div class="figure ml-4">
<a href="https://lunanode.com/" target="_blank">
<img src="~/img/lunanode.svg" alt="Sponsor LunaNode" height="75" />
</a>
<div class="figure-caption text-center">
<a href="https://lunanode.com/" class="text-muted small" target="_blank">LunaNode</a>
</div>
</div>
<div class="figure ml-4">
<a href="https://walletofsatoshi.com/" target="_blank">
<img src="~/img/walletofsatoshi.svg" alt="Sponsor Wallet of Satoshi" height="75" />
</a>
<div class="figure-caption text-center">
<a href="https://walletofsatoshi.com/" class="text-muted small" target="_blank">Wallet of Satoshi</a>
</div>
</div>
@await Html.PartialAsync("_BTCPaySupporters")
</div>
<div class="col-md-5 order-md-2 order-1">
@RenderBody()