mirror of
https://github.com/oliverbooth/VpSharp
synced 2024-11-10 03:15:42 +00:00
Move exception messages to resource file
This commit is contained in:
parent
148fd22c7d
commit
35684cccca
162
VpSharp/res/ExceptionMessages.Designer.cs
generated
162
VpSharp/res/ExceptionMessages.Designer.cs
generated
@ -59,6 +59,69 @@ namespace VpSharp {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to The target avatar is not in the world..
|
||||
/// </summary>
|
||||
internal static string AvatarNotInWorld {
|
||||
get {
|
||||
return ResourceManager.GetString("AvatarNotInWorld", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Cannot invite non-existent user..
|
||||
/// </summary>
|
||||
internal static string CannotInviteNonExistentUser {
|
||||
get {
|
||||
return ResourceManager.GetString("CannotInviteNonExistentUser", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Cannot join non-existent user..
|
||||
/// </summary>
|
||||
internal static string CannotJoinNonExistentUser {
|
||||
get {
|
||||
return ResourceManager.GetString("CannotJoinNonExistentUser", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Cannot login due to incomplete configuration..
|
||||
/// </summary>
|
||||
internal static string CannotLogin_IncompleteConfiguration {
|
||||
get {
|
||||
return ResourceManager.GetString("CannotLogin_IncompleteConfiguration", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to The specified username and password constitute an invalid login..
|
||||
/// </summary>
|
||||
internal static string CannotLogin_InvalidLogin {
|
||||
get {
|
||||
return ResourceManager.GetString("CannotLogin_InvalidLogin", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to A value in the configuration is too long. (BotName?).
|
||||
/// </summary>
|
||||
internal static string CannotLogin_StringTooLong {
|
||||
get {
|
||||
return ResourceManager.GetString("CannotLogin_StringTooLong", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to The login request timed out..
|
||||
/// </summary>
|
||||
internal static string CannotLogin_Timeout {
|
||||
get {
|
||||
return ResourceManager.GetString("CannotLogin_Timeout", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to The operation cannot be performed on the client's current avatar..
|
||||
/// </summary>
|
||||
@ -68,6 +131,51 @@ namespace VpSharp {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Connection to the server timed out..
|
||||
/// </summary>
|
||||
internal static string ConnectionTimedOut {
|
||||
get {
|
||||
return ResourceManager.GetString("ConnectionTimedOut", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to A connection to a universe server is required for this operation..
|
||||
/// </summary>
|
||||
internal static string ConnectionToUniverseServerRequired {
|
||||
get {
|
||||
return ResourceManager.GetString("ConnectionToUniverseServerRequired", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to A connection to a world server is required for this operation..
|
||||
/// </summary>
|
||||
internal static string ConnectionToWorldServerRequired {
|
||||
get {
|
||||
return ResourceManager.GetString("ConnectionToWorldServerRequired", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to No extension with the type {0} is added to this client..
|
||||
/// </summary>
|
||||
internal static string NoSuchExtension {
|
||||
get {
|
||||
return ResourceManager.GetString("NoSuchExtension", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Not allowed to modify world settings..
|
||||
/// </summary>
|
||||
internal static string NotAllowedToModifyWorldSettings {
|
||||
get {
|
||||
return ResourceManager.GetString("NotAllowedToModifyWorldSettings", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to An attempt was made to perform an operation that requires a connection to a world server..
|
||||
/// </summary>
|
||||
@ -86,6 +194,15 @@ namespace VpSharp {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Radius must be greater than or equal to 1..
|
||||
/// </summary>
|
||||
internal static string RadiusMustBeGreaterThan1 {
|
||||
get {
|
||||
return ResourceManager.GetString("RadiusMustBeGreaterThan1", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to A specified value is too long..
|
||||
/// </summary>
|
||||
@ -95,6 +212,24 @@ namespace VpSharp {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Type cannot be abstract..
|
||||
/// </summary>
|
||||
internal static string TypeCannotBeAbstract {
|
||||
get {
|
||||
return ResourceManager.GetString("TypeCannotBeAbstract", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Type must inherit from {0}..
|
||||
/// </summary>
|
||||
internal static string TypeMustInherit {
|
||||
get {
|
||||
return ResourceManager.GetString("TypeMustInherit", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to The specified remote endpoint is not supported..
|
||||
/// </summary>
|
||||
@ -104,6 +239,33 @@ namespace VpSharp {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Unsupported object type..
|
||||
/// </summary>
|
||||
internal static string UnsupportedObjectType {
|
||||
get {
|
||||
return ResourceManager.GetString("UnsupportedObjectType", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Value cannot be empty..
|
||||
/// </summary>
|
||||
internal static string ValueCannotBeEmpty {
|
||||
get {
|
||||
return ResourceManager.GetString("ValueCannotBeEmpty", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Connection to the universe server was lost, or connecting to the world failed..
|
||||
/// </summary>
|
||||
internal static string WorldLoginError {
|
||||
get {
|
||||
return ResourceManager.GetString("WorldLoginError", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to World name cannot be null or empty..
|
||||
/// </summary>
|
||||
|
@ -24,21 +24,75 @@
|
||||
</value>
|
||||
</resheader>
|
||||
|
||||
<data name="AvatarNotInWorld" xml:space="preserve">
|
||||
<value>The target avatar is not in the world.</value>
|
||||
</data>
|
||||
<data name="CannotInviteNonExistentUser" xml:space="preserve">
|
||||
<value>Cannot invite non-existent user.</value>
|
||||
</data>
|
||||
<data name="CannotJoinNonExistentUser" xml:space="preserve">
|
||||
<value>Cannot join non-existent user.</value>
|
||||
</data>
|
||||
<data name="CannotLogin_IncompleteConfiguration" xml:space="preserve">
|
||||
<value>Cannot login due to incomplete configuration.</value>
|
||||
</data>
|
||||
<data name="CannotLogin_InvalidLogin" xml:space="preserve">
|
||||
<value>The specified username and password constitute an invalid login.</value>
|
||||
</data>
|
||||
<data name="CannotLogin_StringTooLong" xml:space="preserve">
|
||||
<value>A value in the configuration is too long. (BotName?)</value>
|
||||
</data>
|
||||
<data name="CannotLogin_Timeout" xml:space="preserve">
|
||||
<value>The login request timed out.</value>
|
||||
</data>
|
||||
<data name="CannotUseSelf" xml:space="preserve">
|
||||
<value>The operation cannot be performed on the client's current avatar.</value>
|
||||
</data>
|
||||
<data name="ConnectionTimedOut" xml:space="preserve">
|
||||
<value>Connection to the server timed out.</value>
|
||||
</data>
|
||||
<data name="ConnectionToUniverseServerRequired" xml:space="preserve">
|
||||
<value>A connection to a universe server is required for this operation.</value>
|
||||
</data>
|
||||
<data name="ConnectionToWorldServerRequired" xml:space="preserve">
|
||||
<value>A connection to a world server is required for this operation.</value>
|
||||
</data>
|
||||
<data name="NoSuchExtension" xml:space="preserve">
|
||||
<value>No extension with the type {0} is added to this client.</value>
|
||||
</data>
|
||||
<data name="NotAllowedToModifyWorldSettings" xml:space="preserve">
|
||||
<value>Not allowed to modify world settings.</value>
|
||||
</data>
|
||||
<data name="NotInWorld" xml:space="preserve">
|
||||
<value>An attempt was made to perform an operation that requires a connection to a world server.</value>
|
||||
</data>
|
||||
<data name="ObjectNotFound" xml:space="preserve">
|
||||
<value>An attempt was made to perform an operation on a nonexistent object.</value>
|
||||
</data>
|
||||
<data name="RadiusMustBeGreaterThan1" xml:space="preserve">
|
||||
<value>Radius must be greater than or equal to 1.</value>
|
||||
</data>
|
||||
<data name="StringTooLong" xml:space="preserve">
|
||||
<value>A specified value is too long.</value>
|
||||
</data>
|
||||
<data name="TypeCannotBeAbstract" xml:space="preserve">
|
||||
<value>Type cannot be abstract.</value>
|
||||
</data>
|
||||
<data name="TypeMustInherit" xml:space="preserve">
|
||||
<value>Type must inherit from {0}.</value>
|
||||
</data>
|
||||
<data name="UnsupportedEndpoint" xml:space="preserve">
|
||||
<value>The specified remote endpoint is not supported.</value>
|
||||
</data>
|
||||
<data name="UnsupportedObjectType" xml:space="preserve">
|
||||
<value>Unsupported object type.</value>
|
||||
</data>
|
||||
<data name="ValueCannotBeEmpty" xml:space="preserve">
|
||||
<value>Value cannot be empty.</value>
|
||||
</data>
|
||||
<data name="WorldLoginError" xml:space="preserve">
|
||||
Connection to the universe server was lost, or connecting to the world failed.
|
||||
</data>
|
||||
<data name="WorldNameCannotBeEmpty" xml:space="preserve">
|
||||
<value>World name cannot be null or empty.</value>
|
||||
</data>
|
||||
|
@ -217,7 +217,7 @@ public sealed class VirtualParadiseAvatar : IEquatable<VirtualParadiseAvatar>
|
||||
ArgumentNullException.ThrowIfNull(message);
|
||||
if (string.IsNullOrWhiteSpace(message))
|
||||
{
|
||||
throw new ArgumentException("Message cannot be empty.");
|
||||
throw new ArgumentException(ExceptionMessages.ValueCannotBeEmpty, nameof(message));
|
||||
}
|
||||
|
||||
VirtualParadiseAvatar avatar;
|
||||
@ -240,13 +240,13 @@ public sealed class VirtualParadiseAvatar : IEquatable<VirtualParadiseAvatar>
|
||||
switch (reason)
|
||||
{
|
||||
case ReasonCode.NotInWorld when _client.CurrentAvatar is null:
|
||||
throw new InvalidOperationException("A connection to the world server is required to send messages.");
|
||||
throw new InvalidOperationException(ExceptionMessages.ConnectionToWorldServerRequired);
|
||||
|
||||
case ReasonCode.NotInWorld:
|
||||
throw new InvalidOperationException("The recipient avatar is not in this world.");
|
||||
throw new InvalidOperationException(ExceptionMessages.AvatarNotInWorld);
|
||||
|
||||
case ReasonCode.StringTooLong:
|
||||
throw new ArgumentException("The message is too long to send.");
|
||||
throw new ArgumentException(ExceptionMessages.StringTooLong);
|
||||
}
|
||||
}
|
||||
|
||||
@ -354,7 +354,7 @@ public sealed class VirtualParadiseAvatar : IEquatable<VirtualParadiseAvatar>
|
||||
#else
|
||||
if (string.IsNullOrEmpty(world))
|
||||
{
|
||||
throw new ArgumentException("World cannot be empty");
|
||||
throw new ArgumentException(ExceptionMessages.ValueCannotBeEmpty, nameof(world));
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -156,9 +156,8 @@ public sealed class VirtualParadiseUser : IEquatable<VirtualParadiseUser>
|
||||
ReasonCode.Success => InviteResponse.Accepted,
|
||||
ReasonCode.InviteDeclined => InviteResponse.Declined,
|
||||
ReasonCode.Timeout => InviteResponse.TimeOut,
|
||||
ReasonCode.NoSuchUser => throw new UserNotFoundException($"Cannot invite non-existent user {Id}."),
|
||||
var _ => throw new InvalidOperationException(
|
||||
$"An error occurred trying to invite the user: {reason:D} ({reason:G})")
|
||||
ReasonCode.NoSuchUser => throw new UserNotFoundException(ExceptionMessages.CannotInviteNonExistentUser),
|
||||
_ => throw new VirtualParadiseException(reason)
|
||||
};
|
||||
}
|
||||
|
||||
@ -232,9 +231,8 @@ public sealed class VirtualParadiseUser : IEquatable<VirtualParadiseUser>
|
||||
ReasonCode.Success => JoinResponse.Accepted,
|
||||
ReasonCode.JoinDeclined => JoinResponse.Declined,
|
||||
ReasonCode.Timeout => JoinResponse.TimeOut,
|
||||
ReasonCode.NoSuchUser => throw new UserNotFoundException($"Cannot join non-existent user {Id}."),
|
||||
var _ => throw new InvalidOperationException(
|
||||
$"An error occurred trying to join the user: {reason:D} ({reason:G})")
|
||||
ReasonCode.NoSuchUser => throw new UserNotFoundException(ExceptionMessages.CannotJoinNonExistentUser),
|
||||
_ => throw new VirtualParadiseException(reason)
|
||||
};
|
||||
// ReSharper enable InconsistentlySynchronizedField
|
||||
|
||||
|
@ -50,12 +50,14 @@ public sealed partial class VirtualParadiseClient
|
||||
|
||||
if (!type.IsSubclassOf(typeof(VirtualParadiseClientExtension)))
|
||||
{
|
||||
throw new ArgumentException($"Type must inherit from {typeof(VirtualParadiseClientExtension)}");
|
||||
throw new ArgumentException(
|
||||
string.Format(CultureInfo.InvariantCulture, ExceptionMessages.TypeMustInherit,
|
||||
typeof(VirtualParadiseClientExtension)), nameof(type));
|
||||
}
|
||||
|
||||
if (type.IsAbstract)
|
||||
{
|
||||
throw new ArgumentException("Extension type cannot be abstract");
|
||||
throw new ArgumentException(ExceptionMessages.TypeCannotBeAbstract, nameof(type));
|
||||
}
|
||||
|
||||
object?[] argumentsActual = {this};
|
||||
@ -105,7 +107,8 @@ public sealed partial class VirtualParadiseClient
|
||||
var result = _extensions.Find(e => e.GetType() == typeof(T)) as T;
|
||||
if (result is null)
|
||||
{
|
||||
throw new InvalidOperationException($"No extension with the type {typeof(T)} is added to this client.");
|
||||
throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, ExceptionMessages.NoSuchExtension,
|
||||
typeof(T)));
|
||||
}
|
||||
|
||||
return result;
|
||||
|
@ -54,7 +54,7 @@ public sealed partial class VirtualParadiseClient
|
||||
{
|
||||
if (radius < 0)
|
||||
{
|
||||
throw new ArgumentException("Range must be greater than or equal to 1.");
|
||||
throw new ArgumentException(ExceptionMessages.RadiusMustBeGreaterThan1, nameof(radius));
|
||||
}
|
||||
|
||||
var hashSet = new HashSet<Cell>();
|
||||
@ -144,12 +144,10 @@ public sealed partial class VirtualParadiseClient
|
||||
PreReturn:
|
||||
return reason switch
|
||||
{
|
||||
ReasonCode.DatabaseError =>
|
||||
throw new VirtualParadiseException(ReasonCode.DatabaseError, "Error communicating with the database."),
|
||||
ReasonCode.DatabaseError => throw new VirtualParadiseException(ReasonCode.DatabaseError),
|
||||
ReasonCode.ObjectNotFound => throw new ObjectNotFoundException(),
|
||||
ReasonCode.UnknownError =>
|
||||
throw new VirtualParadiseException(ReasonCode.UnknownError, "An unknown error occurred retrieving the object."),
|
||||
_ when reason != ReasonCode.Success => throw new VirtualParadiseException(reason, $"{reason:D} ({reason:G})"),
|
||||
ReasonCode.UnknownError => throw new VirtualParadiseException(ReasonCode.UnknownError),
|
||||
_ when reason != ReasonCode.Success => throw new VirtualParadiseException(reason),
|
||||
_ => virtualParadiseObject!
|
||||
};
|
||||
}
|
||||
@ -224,7 +222,7 @@ public sealed partial class VirtualParadiseClient
|
||||
ObjectType.Model => new VirtualParadiseModelObject(this, id),
|
||||
ObjectType.ParticleEmitter => new VirtualParadiseParticleEmitterObject(this, id),
|
||||
ObjectType.Path => new VirtualParadisePathObject(this, id),
|
||||
_ => throw new NotSupportedException("Unsupported object type.")
|
||||
_ => throw new NotSupportedException(ExceptionMessages.UnsupportedObjectType)
|
||||
};
|
||||
|
||||
virtualParadiseObject.ExtractFromInstance(sender);
|
||||
|
@ -344,8 +344,7 @@ public sealed partial class VirtualParadiseClient : IDisposable
|
||||
break;
|
||||
|
||||
case ReasonCode.NotInUniverse:
|
||||
throw new InvalidOperationException(
|
||||
"The client must be connected to the universe server in order to enter a world.");
|
||||
throw new InvalidOperationException(ExceptionMessages.ConnectionToUniverseServerRequired);
|
||||
|
||||
case ReasonCode.StringTooLong:
|
||||
ThrowHelper.ThrowStringTooLongException(nameof(worldName));
|
||||
@ -353,17 +352,16 @@ public sealed partial class VirtualParadiseClient : IDisposable
|
||||
|
||||
case ReasonCode.ConnectionError:
|
||||
case ReasonCode.WorldLoginError:
|
||||
throw new VirtualParadiseException(reason,
|
||||
"Connection to the universe server was lost, or connecting to the world failed.");
|
||||
throw new VirtualParadiseException(reason, ExceptionMessages.WorldLoginError);
|
||||
|
||||
case ReasonCode.WorldNotFound:
|
||||
throw new WorldNotFoundException(worldName);
|
||||
|
||||
case ReasonCode.Timeout:
|
||||
throw new TimeoutException("Connection to the world server timed out.");
|
||||
throw new TimeoutException(ExceptionMessages.ConnectionTimedOut);
|
||||
|
||||
default:
|
||||
throw new VirtualParadiseException(reason, $"Unknown error: {reason:D} ({reason:G})");
|
||||
throw new VirtualParadiseException(reason);
|
||||
}
|
||||
|
||||
int size;
|
||||
@ -483,7 +481,7 @@ public sealed partial class VirtualParadiseClient : IDisposable
|
||||
|
||||
if (string.IsNullOrWhiteSpace(username) || string.IsNullOrWhiteSpace(password) || string.IsNullOrWhiteSpace(botName))
|
||||
{
|
||||
throw new ArgumentException("Cannot login due to incomplete configuration.");
|
||||
throw new ArgumentException(ExceptionMessages.CannotLogin_IncompleteConfiguration);
|
||||
}
|
||||
|
||||
_loginCompletionSource = new TaskCompletionSource<ReasonCode>();
|
||||
@ -512,16 +510,16 @@ public sealed partial class VirtualParadiseClient : IDisposable
|
||||
switch (reason)
|
||||
{
|
||||
case ReasonCode.Timeout:
|
||||
throw new TimeoutException("The login request timed out.");
|
||||
throw new TimeoutException(ExceptionMessages.CannotLogin_Timeout);
|
||||
|
||||
case ReasonCode.InvalidLogin:
|
||||
throw new InvalidCredentialException("The specified username and password constitute an invalid login.");
|
||||
throw new InvalidCredentialException(ExceptionMessages.CannotLogin_InvalidLogin);
|
||||
|
||||
case ReasonCode.StringTooLong:
|
||||
throw new ArgumentException($"A value in the configuration is too long. ({nameof(_configuration.BotName)}?)");
|
||||
throw new ArgumentException(ExceptionMessages.CannotLogin_StringTooLong);
|
||||
|
||||
case ReasonCode.NotInUniverse:
|
||||
throw new InvalidOperationException("A connection to the universe server is required to attempt login.");
|
||||
throw new InvalidOperationException(ExceptionMessages.ConnectionToUniverseServerRequired);
|
||||
}
|
||||
|
||||
int userId;
|
||||
@ -554,7 +552,7 @@ public sealed partial class VirtualParadiseClient : IDisposable
|
||||
ArgumentNullException.ThrowIfNull(message);
|
||||
if (string.IsNullOrWhiteSpace(message))
|
||||
{
|
||||
throw new ArgumentException("Message cannot be empty.");
|
||||
throw new ArgumentException(ExceptionMessages.ValueCannotBeEmpty, nameof(message));
|
||||
}
|
||||
|
||||
lock (Lock)
|
||||
@ -565,10 +563,10 @@ public sealed partial class VirtualParadiseClient : IDisposable
|
||||
switch (reason)
|
||||
{
|
||||
case ReasonCode.NotInWorld:
|
||||
throw new InvalidOperationException("A connection to the world server is required to send messages.");
|
||||
throw new InvalidOperationException(ExceptionMessages.ConnectionToWorldServerRequired);
|
||||
|
||||
case ReasonCode.StringTooLong:
|
||||
throw new ArgumentException("The message is too long to send.");
|
||||
throw new ArgumentException(ExceptionMessages.StringTooLong);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -396,7 +396,7 @@ public sealed class WorldSettingsBuilder
|
||||
|
||||
if (reason == ReasonCode.NotAllowed)
|
||||
{
|
||||
throw new UnauthorizedAccessException("Not allowed to modify world settings.");
|
||||
throw new UnauthorizedAccessException(ExceptionMessages.NotAllowedToModifyWorldSettings);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user