-
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.
* Implemented exception handling. * Fixed empty roster bug. * Allow to receive regions and types as unique names. * Implementing an edit modal. * Fixed SearchNumber. * Using library components. * Using library components. * Using library components.
- Loading branch information
Showing
38 changed files
with
777 additions
and
389 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
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,18 @@ | ||
namespace PokeData.Contracts.Errors; | ||
|
||
public record Error | ||
{ | ||
public string Code { get; set; } | ||
public string Message { get; set; } | ||
public List<ErrorData>? Data { get; set; } | ||
|
||
public Error() : this(string.Empty, string.Empty) | ||
{ | ||
} | ||
public Error(string code, string message, IEnumerable<ErrorData>? data = null) | ||
{ | ||
Code = code; | ||
Message = message; | ||
Data = data?.ToList(); | ||
} | ||
} |
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,16 @@ | ||
namespace PokeData.Contracts.Errors; | ||
|
||
public record ErrorData | ||
{ | ||
public string Key { get; set; } | ||
public string? Value { get; set; } | ||
|
||
public ErrorData() : this(string.Empty) | ||
{ | ||
} | ||
public ErrorData(string key, object? value = null) | ||
{ | ||
Key = key; | ||
Value = value?.ToString(); | ||
} | ||
} |
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,6 @@ | ||
namespace PokeData.Contracts.Errors; | ||
|
||
public interface IErrorException | ||
{ | ||
Error Error { get; } | ||
} |
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
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
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,43 @@ | ||
using FluentValidation; | ||
using Microsoft.AspNetCore.Mvc; | ||
using Microsoft.AspNetCore.Mvc.Filters; | ||
using PokeData.Application; | ||
|
||
namespace PokeData.Filters; | ||
|
||
internal class PokemonExceptionFilter : ExceptionFilterAttribute | ||
{ | ||
private readonly Dictionary<Type, Func<ExceptionContext, IActionResult>> _handlers = new() | ||
{ | ||
[typeof(ValidationException)] = HandleValidationException | ||
}; | ||
|
||
public override void OnException(ExceptionContext context) | ||
{ | ||
if (_handlers.TryGetValue(context.Exception.GetType(), out Func<ExceptionContext, IActionResult>? handler)) | ||
{ | ||
context.Result = handler(context); | ||
context.ExceptionHandled = true; | ||
} | ||
else if (context.Exception is AggregateNotFoundException aggregateNotFound) | ||
{ | ||
context.Result = new NotFoundObjectResult(aggregateNotFound.Error); | ||
context.ExceptionHandled = true; | ||
} | ||
else if (context.Exception is TooManyResultsException tooManyResults) | ||
{ | ||
context.Result = new BadRequestObjectResult(tooManyResults.Error); | ||
context.ExceptionHandled = true; | ||
} | ||
else | ||
{ | ||
base.OnException(context); | ||
} | ||
} | ||
|
||
private static BadRequestObjectResult HandleValidationException(ExceptionContext context) | ||
{ | ||
ValidationException exception = (ValidationException)context.Exception; | ||
return new BadRequestObjectResult(new { exception.Errors }); | ||
} | ||
} |
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 |
---|---|---|
@@ -1,2 +1,2 @@ | ||
VITE_APP_API_BASE_URL="http://localhost:43551/" | ||
__VITE_APP_API_BASE_URL="https://localhost:32768/" | ||
__VITE_APP_API_BASE_URL="http://localhost:43551/" | ||
VITE_APP_API_BASE_URL="https://localhost:32770/" |
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,48 @@ | ||
<script setup lang="ts"> | ||
import { TarInput, type InputSize } from "logitar-vue3-ui"; | ||
import { computed } from "vue"; | ||
const props = withDefaults( | ||
defineProps<{ | ||
disabled?: boolean; | ||
floating?: boolean; | ||
id?: string; | ||
label?: string; | ||
max?: number; | ||
min?: number; | ||
modelValue?: string; | ||
placeholder?: string; | ||
required?: boolean; | ||
size?: InputSize; | ||
}>(), | ||
{ | ||
floating: true, | ||
id: "category", | ||
label: "Category", | ||
max: 128, | ||
}, | ||
); | ||
const inputPlaceholder = computed<string | undefined>(() => (props.floating ? props.placeholder ?? props.label : props.placeholder)); | ||
defineEmits<{ | ||
(e: "update:model-value", value?: string): void; | ||
}>(); | ||
</script> | ||
|
||
<template> | ||
<TarInput | ||
:disabled="disabled" | ||
:floating="floating" | ||
:id="id" | ||
:label="label" | ||
:max="max" | ||
:min="min" | ||
:model-value="modelValue" | ||
:placeholder="inputPlaceholder" | ||
:required="required" | ||
:size="size" | ||
type="text" | ||
@update:model-value="$emit('update:model-value', $event)" | ||
/> | ||
</template> |
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,48 @@ | ||
<script setup lang="ts"> | ||
import { TarInput, type InputSize } from "logitar-vue3-ui"; | ||
import { computed } from "vue"; | ||
const props = withDefaults( | ||
defineProps<{ | ||
disabled?: boolean; | ||
floating?: boolean; | ||
id?: string; | ||
label?: string; | ||
max?: number; | ||
min?: number; | ||
modelValue?: string; | ||
placeholder?: string; | ||
required?: boolean; | ||
size?: InputSize; | ||
}>(), | ||
{ | ||
floating: true, | ||
id: "name", | ||
label: "Name", | ||
max: 128, | ||
}, | ||
); | ||
const inputPlaceholder = computed<string | undefined>(() => (props.floating ? props.placeholder ?? props.label : props.placeholder)); | ||
defineEmits<{ | ||
(e: "update:model-value", value?: string): void; | ||
}>(); | ||
</script> | ||
|
||
<template> | ||
<TarInput | ||
:disabled="disabled" | ||
:floating="floating" | ||
:id="id" | ||
:label="label" | ||
:max="max" | ||
:min="min" | ||
:model-value="modelValue" | ||
:placeholder="inputPlaceholder" | ||
:required="required" | ||
:size="size" | ||
type="text" | ||
@update:model-value="$emit('update:model-value', $event)" | ||
/> | ||
</template> |
Oops, something went wrong.