This repository has been archived by the owner on Dec 2, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
# Conflicts: # .github/workflows/nuget.yml # ExceptionAll.Tests/ExceptionAll.Tests.csproj # ExceptionAll/Filters/ExceptionFilter.cs # README.md
- Loading branch information
Showing
129 changed files
with
2,531 additions
and
1,768 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<Router AppAssembly="@typeof(App).Assembly"> | ||
<Found Context="routeData"> | ||
<RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)" /> | ||
<FocusOnNavigate RouteData="@routeData" Selector="h1" /> | ||
</Found> | ||
<NotFound> | ||
<PageTitle>Not found</PageTitle> | ||
<LayoutView Layout="@typeof(MainLayout)"> | ||
<p role="alert">Sorry, there's nothing at this address.</p> | ||
</LayoutView> | ||
</NotFound> | ||
</Router> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net6.0</TargetFramework> | ||
<Nullable>enable</Nullable> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="6.0.1" /> | ||
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="6.0.1" PrivateAssets="all" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\..\src\ExceptionAll.Abstractions\ExceptionAll.Abstractions.csproj" /> | ||
<ProjectReference Include="..\..\src\ExceptionAll.Client\ExceptionAll.Client.csproj" /> | ||
<ProjectReference Include="..\Shared\Example.Shared.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
@page "/counter" | ||
|
||
<PageTitle>Counter</PageTitle> | ||
|
||
<h1>Counter</h1> | ||
|
||
<p role="status">Current count: @currentCount</p> | ||
|
||
<button class="btn btn-primary" @onclick="IncrementCount">Click me</button> | ||
|
||
@code { | ||
private int currentCount = 0; | ||
|
||
private void IncrementCount() | ||
{ | ||
currentCount++; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
@page "/fetchdata" | ||
@using Example.Shared | ||
@inject HttpClient Http | ||
|
||
<PageTitle>Weather forecast</PageTitle> | ||
|
||
<h1>Weather forecast</h1> | ||
|
||
<p>This component demonstrates fetching data from the server.</p> | ||
|
||
@if (forecasts == null) | ||
{ | ||
<p><em>Loading...</em></p> | ||
} | ||
else | ||
{ | ||
<table class="table"> | ||
<thead> | ||
<tr> | ||
<th>Date</th> | ||
<th>Temp. (C)</th> | ||
<th>Temp. (F)</th> | ||
<th>Summary</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
@foreach (var forecast in forecasts) | ||
{ | ||
<tr> | ||
<td>@forecast.Date.ToShortDateString()</td> | ||
<td>@forecast.TemperatureC</td> | ||
<td>@forecast.TemperatureF</td> | ||
<td>@forecast.Summary</td> | ||
</tr> | ||
} | ||
</tbody> | ||
</table> | ||
} | ||
|
||
@code { | ||
private WeatherForecast[]? forecasts; | ||
|
||
protected override async Task OnInitializedAsync() | ||
{ | ||
forecasts = await Http.GetFromJsonAsync<WeatherForecast[]>("WeatherForecast"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
@page "/" | ||
@using ExceptionAll.Abstractions.Models | ||
@using Example.Shared | ||
@using ExceptionAll.Client.Exceptions | ||
@using ExceptionAll.Client.Interfaces | ||
@inject IExceptionAllClientFactory _exceptionAllClientFactory | ||
|
||
<PageTitle>Index</PageTitle> | ||
|
||
<button @onclick="@Endpoint1">Endpoint 1</button> | ||
<button @onclick="@Endpoint2">Endpoint 2</button> | ||
<button @onclick="@Endpoint3">Endpoint 3</button> | ||
<button @onclick="@Endpoint4">Endpoint 4</button> | ||
|
||
<br/> | ||
|
||
<h1>Error Details</h1> | ||
<br/> | ||
@if (_errorDetails != null) | ||
{ | ||
<h2>Title: @_errorDetails.Title</h2> <br/> | ||
<h2>Message: @_errorDetails.Message</h2> <br/> | ||
<h2>StatusCode: @_errorDetails.StatusCode.ToString()</h2> | ||
<br/> | ||
@foreach (var detail in _errorDetails.ContextDetails) | ||
{ | ||
<h2>@detail.Key: @detail.Value</h2> | ||
<br/> | ||
} | ||
} | ||
|
||
<h1>Forecast</h1> | ||
<br/> | ||
@if (_forecasts != null) | ||
{ | ||
@foreach (var forecast in _forecasts) | ||
{ | ||
<h2>@forecast.Summary</h2> <br/> | ||
} | ||
} | ||
|
||
@code | ||
{ | ||
private ApiErrorDetails? _errorDetails; | ||
private WeatherForecast[]? _forecasts; | ||
private IExceptionAllClient _exceptionAllClient; | ||
private IExceptionAllClient _clientWithHeader; | ||
|
||
protected override void OnInitialized() | ||
{ | ||
_exceptionAllClient = _exceptionAllClientFactory.CreateClient(); | ||
_clientWithHeader = _exceptionAllClientFactory.CreateClient("Test"); | ||
} | ||
|
||
private async Task Endpoint1() | ||
{ | ||
try | ||
{ | ||
_forecasts = await _exceptionAllClient.GetContentAsync<WeatherForecast[]>("https://localhost:44304/WeatherForecast"); | ||
_errorDetails = null; | ||
} | ||
catch (ExceptionAllException e) | ||
{ | ||
_errorDetails = e.ErrorDetails; | ||
_forecasts = null; | ||
} | ||
} | ||
|
||
private async Task Endpoint2() | ||
{ | ||
try | ||
{ | ||
_forecasts = await _exceptionAllClient.GetContentAsync<WeatherForecast[]>("https://localhost:44304/WeatherForecast/api/GetNullRefError?param=1"); | ||
_errorDetails = null; | ||
} | ||
catch (ExceptionAllException e) | ||
{ | ||
_errorDetails = e.ErrorDetails; | ||
_forecasts = null; | ||
} | ||
} | ||
|
||
private async Task Endpoint3() | ||
{ | ||
try | ||
{ | ||
_forecasts = await _clientWithHeader.GetContentAsync<WeatherForecast[]>("https://localhost:44304/WeatherForecast/api/GetSomething?test=123"); | ||
_errorDetails = null; | ||
} | ||
catch (ExceptionAllException e) | ||
{ | ||
_errorDetails = e.ErrorDetails; | ||
_forecasts = null; | ||
} | ||
} | ||
|
||
private async Task Endpoint4() | ||
{ | ||
try | ||
{ | ||
_forecasts = await _clientWithHeader.GetContentAsync<WeatherForecast[]>("https://localhost:44304/WeatherForecast/api/success"); | ||
_errorDetails = null; | ||
} | ||
catch (ExceptionAllException e) | ||
{ | ||
_errorDetails = e.ErrorDetails; | ||
_forecasts = null; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
using Example.Client; | ||
using ExceptionAll.Client.Helpers; | ||
using Microsoft.AspNetCore.Components.Web; | ||
using Microsoft.AspNetCore.Components.WebAssembly.Hosting; | ||
|
||
var builder = WebAssemblyHostBuilder.CreateDefault(args); | ||
builder.RootComponents.Add<App>("#app"); | ||
builder.RootComponents.Add<HeadOutlet>("head::after"); | ||
|
||
builder.Services.AddExceptionAllClientServices(); | ||
|
||
// Addition of a standard http client | ||
builder.Services.AddHttpClient(); | ||
|
||
// Addition of a different http client, which has a special header for tracing | ||
builder.Services.AddHttpClient("Test", x => | ||
{ | ||
x.DefaultRequestHeaders.Add("x-correlation-id", Guid.NewGuid().ToString()); | ||
}); | ||
|
||
builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) }); | ||
|
||
await builder.Build().RunAsync(); |
23 changes: 11 additions & 12 deletions
23
...APIExample/Properties/launchSettings.json → ...ple/Client/Properties/launchSettings.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
@inherits LayoutComponentBase | ||
|
||
<div class="page"> | ||
<div class="sidebar"> | ||
<NavMenu /> | ||
</div> | ||
|
||
<main> | ||
<div class="top-row px-4"> | ||
<a href="https://docs.microsoft.com/aspnet/" target="_blank">About</a> | ||
</div> | ||
|
||
<article class="content px-4"> | ||
@Body | ||
</article> | ||
</main> | ||
</div> |
Oops, something went wrong.