mirror of
https://github.com/oliverbooth/VpSharp
synced 2024-11-22 19:38:47 +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)
|
||||
{
|
||||
var innerException = new Exception($"Could not instantiate {moduleType.FullName}");
|
||||
throw new TypeInitializationException(moduleType.FullName, innerException);
|
||||
throw new TypeInitializationException(moduleType.FullName, null);
|
||||
}
|
||||
|
||||
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);
|
||||
if (instance is not VirtualParadiseClientExtension extension)
|
||||
{
|
||||
var innerException = new Exception($"Could not instantiate {type}");
|
||||
throw new TypeInitializationException(type.FullName, innerException);
|
||||
throw new TypeInitializationException(type.FullName, null);
|
||||
}
|
||||
|
||||
_extensions.Add(extension);
|
||||
|
@ -125,10 +125,12 @@ public sealed partial class VirtualParadiseClient
|
||||
PreReturn:
|
||||
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.UnknownError => throw new Exception("An unknown error occurred retrieving the object."),
|
||||
_ when reason != ReasonCode.Success => throw new Exception($"{reason:D} ({reason:G})"),
|
||||
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})"),
|
||||
_ => virtualParadiseObject!
|
||||
};
|
||||
}
|
||||
|
@ -334,7 +334,8 @@ public sealed partial class VirtualParadiseClient : IDisposable
|
||||
|
||||
case ReasonCode.ConnectionError:
|
||||
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:
|
||||
throw new WorldNotFoundException(worldName);
|
||||
@ -343,7 +344,7 @@ public sealed partial class VirtualParadiseClient : IDisposable
|
||||
throw new TimeoutException("Connection to the world server timed out.");
|
||||
|
||||
default:
|
||||
throw new Exception($"Unknown error: {reason:D} ({reason:G})");
|
||||
throw new VirtualParadiseException(reason, $"Unknown error: {reason:D} ({reason:G})");
|
||||
}
|
||||
|
||||
int size;
|
||||
|
Loading…
Reference in New Issue
Block a user