-
Notifications
You must be signed in to change notification settings - Fork 49
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
feat: Implement ViewMapNotFoundException
s
#2425
Open
xperiandri
wants to merge
1
commit into
unoplatform:main
Choose a base branch
from
Ecierge:ViewMapNotFoundException
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
141 changes: 141 additions & 0 deletions
141
src/Uno.Extensions.Navigation/ViewMapNotFoundException.cs
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,141 @@ | ||
namespace Uno.Extensions.Navigation; | ||
|
||
/// <summary> | ||
/// Represents an exception that is thrown when a view map is not found in the view registry. | ||
/// </summary> | ||
public class ViewMapNotFoundException : Exception | ||
{ | ||
/// <summary>Initializes a new instance of the <see cref="ViewMapNotFoundException"></see> class.</summary> | ||
private ViewMapNotFoundException() { } | ||
|
||
/// <summary>Initializes a new instance of the <see cref="ViewMapNotFoundException"></see> class with a specified error message.</summary> | ||
/// <param name="message">The message that describes the error.</param> | ||
public ViewMapNotFoundException(string message) : base(message) { } | ||
|
||
/// <summary>Initializes a new instance of the <see cref="ViewMapNotFoundException"></see> class with a specified error message and a reference to the inner exception that is the cause of this exception.</summary> | ||
/// <param name="message">The error message that explains the reason for the exception.</param> | ||
/// <param name="innerException">The exception that is the cause of the current exception, or a null reference (Nothing in Visual Basic) if no inner exception is specified.</param> | ||
public ViewMapNotFoundException(string message, Exception innerException) : base(message, innerException) { } | ||
} | ||
|
||
/// <summary> | ||
/// Represents an exception that is thrown when a view map is not found in the view registry. | ||
/// </summary> | ||
public class ViewMapNotFoundByViewException : ViewMapNotFoundException | ||
{ | ||
/// <summary>Initializes a new instance of the <see cref="ViewMapNotFoundException"></see> class with a specified error message.</summary> | ||
/// <param name="viewType">The view type that was not found in the view registry.</param> | ||
public ViewMapNotFoundByViewException(Type viewType) : base(CreateViewTypeNotFoundMessage(viewType)) { } | ||
|
||
/// <summary>Initializes a new instance of the <see cref="ViewMapNotFoundException"></see> class with a specified error message and a reference to the inner exception that is the cause of this exception.</summary> | ||
/// <param name="viewType">The view type that was not found in the view registry.</param> | ||
/// <param name="innerException">The exception that is the cause of the current exception, or a null reference (Nothing in Visual Basic) if no inner exception is specified.</param> | ||
public ViewMapNotFoundByViewException(Type viewType, Exception innerException) : base(CreateViewTypeNotFoundMessage(viewType), innerException) { } | ||
|
||
/// <summary>Initializes a new instance of the <see cref="ViewMapNotFoundByViewException"></see> class with a specified error message.</summary> | ||
/// <param name="message">The message that describes the error.</param> | ||
private ViewMapNotFoundByViewException(string message) : base(message) { } | ||
|
||
/// <summary>Initializes a new instance of the <see cref="ViewMapNotFoundByViewException"></see> class with a specified error message and a reference to the inner exception that is the cause of this exception.</summary> | ||
/// <param name="message">The error message that explains the reason for the exception.</param> | ||
/// <param name="innerException">The exception that is the cause of the current exception, or a null reference (Nothing in Visual Basic) if no inner exception is specified.</param> | ||
private ViewMapNotFoundByViewException(string message, Exception innerException) : base(message, innerException) { } | ||
|
||
/// <summary> | ||
/// Creates a message that describes the error when a view model type is not found in the view registry. | ||
/// </summary> | ||
/// <param name="viewType"></param> | ||
/// <returns></returns> | ||
public static string CreateViewTypeNotFoundMessage(Type viewType) => $"The view type {viewType} was not found in the view registry."; | ||
} | ||
|
||
/// <summary> | ||
/// Represents an exception that is thrown when a view map is not found in the view registry. | ||
/// </summary> | ||
public class ViewMapNotFoundByViewModelException : ViewMapNotFoundException | ||
{ | ||
/// <summary>Initializes a new instance of the <see cref="ViewMapNotFoundException"></see> class with a specified error message and a reference to the inner exception that is the cause of this exception.</summary> | ||
/// <param name="viewModelType">The view model type that was not found in the view registry.</param> | ||
/// <param name="innerException">The exception that is the cause of the current exception, or a null reference (Nothing in Visual Basic) if no inner exception is specified.</param> | ||
public ViewMapNotFoundByViewModelException(Type viewModelType, Exception innerException) : base(CreateViewModelTypeNotFoundMessage(viewModelType), innerException) { } | ||
|
||
/// <summary>Initializes a new instance of the <see cref="ViewMapNotFoundException"></see> class with a specified error message.</summary> | ||
/// <param name="viewType">The view type that was not found in the view registry.</param> | ||
public ViewMapNotFoundByViewModelException(Type viewType) : base(CreateViewModelTypeNotFoundMessage(viewType)) { } | ||
|
||
/// <summary>Initializes a new instance of the <see cref="ViewMapNotFoundByViewModelException"></see> class with a specified error message.</summary> | ||
/// <param name="message">The message that describes the error.</param> | ||
private ViewMapNotFoundByViewModelException(string message) : base(message) { } | ||
|
||
/// <summary>Initializes a new instance of the <see cref="ViewMapNotFoundByViewModelException"></see> class with a specified error message and a reference to the inner exception that is the cause of this exception.</summary> | ||
/// <param name="message">The error message that explains the reason for the exception.</param> | ||
/// <param name="innerException">The exception that is the cause of the current exception, or a null reference (Nothing in Visual Basic) if no inner exception is specified.</param> | ||
private ViewMapNotFoundByViewModelException(string message, Exception innerException) : base(message, innerException) { } | ||
|
||
/// <summary> | ||
/// Creates a message that describes the error when a view model type is not found in the view registry. | ||
/// </summary> | ||
public static string CreateViewModelTypeNotFoundMessage(Type viewModelType) => $"The view model type {viewModelType} was not found in the view registry."; | ||
} | ||
|
||
/// <summary> | ||
/// Represents an exception that is thrown when a view map is not found in the view registry. | ||
/// </summary> | ||
public class ViewMapNotFoundByDataException : ViewMapNotFoundException | ||
{ | ||
/// <summary>Initializes a new instance of the <see cref="ViewMapNotFoundByDataException"/> class with a specified error message.</summary> | ||
/// <param name="dataType">The data type that was not found in the view registry.</param> | ||
public ViewMapNotFoundByDataException(Type dataType) : base(CreateDataTypeNotFoundMessage(dataType)) { } | ||
|
||
/// <summary>Initializes a new instance of the <see cref="ViewMapNotFoundByDataException"/> class with a specified error message and a reference to the inner exception that is the cause of this exception.</summary> | ||
/// <param name="dataType">The data type that was not found in the view registry.</param> | ||
/// <param name="innerException">The exception that is the cause of the current exception, or a null reference (Nothing in Visual Basic) if no inner exception is specified.</param> | ||
public ViewMapNotFoundByDataException(Type dataType, Exception innerException) : base(CreateDataTypeNotFoundMessage(dataType), innerException) { } | ||
|
||
/// <summary>Initializes a new instance of the <see cref="ViewMapNotFoundByDataException"/> class with a specified error message.</summary> | ||
/// <param name="message">The message that describes the error.</param> | ||
private ViewMapNotFoundByDataException(string message) : base(message) { } | ||
|
||
/// <summary>Initializes a new instance of the <see cref="ViewMapNotFoundByDataException"/> class with a specified error message and a reference to the inner exception that is the cause of this exception.</summary> | ||
/// <param name="message">The error message that explains the reason for the exception.</param> | ||
/// <param name="innerException">The exception that is the cause of the current exception, or a null reference (Nothing in Visual Basic) if no inner exception is specified.</param> | ||
private ViewMapNotFoundByDataException(string message, Exception innerException) : base(message, innerException) { } | ||
|
||
/// <summary> | ||
/// Creates a message that describes the error when a data type is not found in the view registry. | ||
/// </summary> | ||
/// <param name="dataType">The data type that was not found in the view registry.</param> | ||
/// <returns>The error message.</returns> | ||
public static string CreateDataTypeNotFoundMessage(Type dataType) => $"The data type {dataType} was not found in the view registry."; | ||
} | ||
|
||
/// <summary> | ||
/// Represents an exception that is thrown when a view map is not found in the view registry. | ||
/// </summary> | ||
public class ViewMapNotFoundByResultDataException : ViewMapNotFoundException | ||
{ | ||
/// <summary>Initializes a new instance of the <see cref="ViewMapNotFoundByResultDataException"/> class with a specified error message.</summary> | ||
/// <param name="resultDataType">The result data type that was not found in the view registry.</param> | ||
public ViewMapNotFoundByResultDataException(Type resultDataType) : base(CreateResultDataTypeNotFoundMessage(resultDataType)) { } | ||
|
||
/// <summary>Initializes a new instance of the <see cref="ViewMapNotFoundByResultDataException"/> class with a specified error message and a reference to the inner exception that is the cause of this exception.</summary> | ||
/// <param name="resultDataType">The result data type that was not found in the view registry.</param> | ||
/// <param name="innerException">The exception that is the cause of the current exception, or a null reference (Nothing in Visual Basic) if no inner exception is specified.</param> | ||
public ViewMapNotFoundByResultDataException(Type resultDataType, Exception innerException) : base(CreateResultDataTypeNotFoundMessage(resultDataType), innerException) { } | ||
|
||
/// <summary>Initializes a new instance of the <see cref="ViewMapNotFoundByResultDataException"/> class with a specified error message.</summary> | ||
/// <param name="message">The message that describes the error.</param> | ||
private ViewMapNotFoundByResultDataException(string message) : base(message) { } | ||
|
||
/// <summary>Initializes a new instance of the <see cref="ViewMapNotFoundByResultDataException"/> class with a specified error message and a reference to the inner exception that is the cause of this exception.</summary> | ||
/// <param name="message">The error message that explains the reason for the exception.</param> | ||
/// <param name="innerException">The exception that is the cause of the current exception, or a null reference (Nothing in Visual Basic) if no inner exception is specified.</param> | ||
private ViewMapNotFoundByResultDataException(string message, Exception innerException) : base(message, innerException) { } | ||
|
||
/// <summary> | ||
/// Creates a message that describes the error when a result data type is not found in the view registry. | ||
/// </summary> | ||
/// <param name="resultDataType">The result data type that was not found in the view registry.</param> | ||
/// <returns>The error message.</returns> | ||
public static string CreateResultDataTypeNotFoundMessage(Type resultDataType) => $"The result data type {resultDataType} was not found in the view registry."; | ||
} |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello @xperiandri, thanks for the PR! Maybe we could simplify a bit and have something like:
Or if it's preferable to have multiple exception types (so they can be caught independently), we could define a base exception class like
ViewMapNotFoundExceptionBase
. In this base class, we can define theCreateTypeNotFoundMessage
method such as:This method can then be used by the other exception classes that inherit from
ViewMapNotFoundExceptionBase
. Remember to use theenum ViewMapSearchType
, please.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I defined a base class.
Type comes from different errors, so different exception types needed