mirror of
https://github.com/oliverbooth/VpSharp
synced 2024-11-10 02:55:41 +00:00
Don't use base Exception
This commit is contained in:
parent
80679fa8c4
commit
548a5de2be
@ -120,8 +120,7 @@ public sealed class CommandsExtension : VirtualParadiseClientExtension
|
|||||||
|
|
||||||
if (Activator.CreateInstance(moduleType) is not CommandModule module)
|
if (Activator.CreateInstance(moduleType) is not CommandModule module)
|
||||||
{
|
{
|
||||||
var innerException = new Exception($"Could not instantiate {moduleType.FullName}");
|
throw new TypeInitializationException(moduleType.FullName, null);
|
||||||
throw new TypeInitializationException(moduleType.FullName, innerException);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (MethodInfo method in moduleType.GetMethods(BindingFlags))
|
foreach (MethodInfo method in moduleType.GetMethods(BindingFlags))
|
||||||
|
@ -68,8 +68,7 @@ public sealed partial class VirtualParadiseClient
|
|||||||
object? instance = Activator.CreateInstance(type, bindingFlags, null, argumentsActual, CultureInfo.InvariantCulture);
|
object? instance = Activator.CreateInstance(type, bindingFlags, null, argumentsActual, CultureInfo.InvariantCulture);
|
||||||
if (instance is not VirtualParadiseClientExtension extension)
|
if (instance is not VirtualParadiseClientExtension extension)
|
||||||
{
|
{
|
||||||
var innerException = new Exception($"Could not instantiate {type}");
|
throw new TypeInitializationException(type.FullName, null);
|
||||||
throw new TypeInitializationException(type.FullName, innerException);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_extensions.Add(extension);
|
_extensions.Add(extension);
|
||||||
|
@ -125,10 +125,12 @@ public sealed partial class VirtualParadiseClient
|
|||||||
PreReturn:
|
PreReturn:
|
||||||
return reason switch
|
return reason switch
|
||||||
{
|
{
|
||||||
ReasonCode.DatabaseError => throw new Exception("Error communicating with the database."),
|
ReasonCode.DatabaseError =>
|
||||||
|
throw new VirtualParadiseException(ReasonCode.DatabaseError, "Error communicating with the database."),
|
||||||
ReasonCode.ObjectNotFound => throw new ObjectNotFoundException(),
|
ReasonCode.ObjectNotFound => throw new ObjectNotFoundException(),
|
||||||
ReasonCode.UnknownError => throw new Exception("An unknown error occurred retrieving the object."),
|
ReasonCode.UnknownError =>
|
||||||
_ when reason != ReasonCode.Success => throw new Exception($"{reason:D} ({reason:G})"),
|
throw new VirtualParadiseException(ReasonCode.UnknownError, "An unknown error occurred retrieving the object."),
|
||||||
|
_ when reason != ReasonCode.Success => throw new VirtualParadiseException(reason, $"{reason:D} ({reason:G})"),
|
||||||
_ => virtualParadiseObject!
|
_ => virtualParadiseObject!
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -334,7 +334,8 @@ public sealed partial class VirtualParadiseClient : IDisposable
|
|||||||
|
|
||||||
case ReasonCode.ConnectionError:
|
case ReasonCode.ConnectionError:
|
||||||
case ReasonCode.WorldLoginError:
|
case ReasonCode.WorldLoginError:
|
||||||
throw new Exception("Connection to the universe server was lost, or connecting to the world failed.");
|
throw new VirtualParadiseException(reason,
|
||||||
|
"Connection to the universe server was lost, or connecting to the world failed.");
|
||||||
|
|
||||||
case ReasonCode.WorldNotFound:
|
case ReasonCode.WorldNotFound:
|
||||||
throw new WorldNotFoundException(worldName);
|
throw new WorldNotFoundException(worldName);
|
||||||
@ -343,7 +344,7 @@ public sealed partial class VirtualParadiseClient : IDisposable
|
|||||||
throw new TimeoutException("Connection to the world server timed out.");
|
throw new TimeoutException("Connection to the world server timed out.");
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw new Exception($"Unknown error: {reason:D} ({reason:G})");
|
throw new VirtualParadiseException(reason, $"Unknown error: {reason:D} ({reason:G})");
|
||||||
}
|
}
|
||||||
|
|
||||||
int size;
|
int size;
|
||||||
|
Loading…
Reference in New Issue
Block a user