Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: mockingbirdnest/Principia
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: adac65146985
Choose a base ref
...
head repository: mockingbirdnest/Principia
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: b7bfa8910538
Choose a head ref
  • 2 commits
  • 2 files changed
  • 1 contributor

Commits on May 23, 2020

  1. Copy the full SHA
    f5118d9 View commit details

Commits on May 24, 2020

  1. Merge pull request #2589 from pleroy/2585

    Use the Status message in the exceptions returned from the external interface
    pleroy authored May 24, 2020
    Copy the full SHA
    b7bfa89 View commit details
Showing with 41 additions and 20 deletions.
  1. +1 −0 Principia.sln.DotSettings
  2. +40 −20 ksp_plugin_adapter/external_interface.cs
1 change: 1 addition & 0 deletions Principia.sln.DotSettings
Original file line number Diff line number Diff line change
@@ -208,6 +208,7 @@
<s:Boolean x:Key="/Default/UserDictionary/Words/=opengl/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=pangram/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=periapsis/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=planetocentric/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Prepending/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=principia/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=prograde/@EntryIndexedValue">True</s:Boolean>
60 changes: 40 additions & 20 deletions ksp_plugin_adapter/external_interface.cs
Original file line number Diff line number Diff line change
@@ -55,33 +55,53 @@ public static ExternalInterface Get() {
return null;
}
foreach (var module in modules) {
if (module is PrincipiaPluginAdapter) {
return new ExternalInterface((PrincipiaPluginAdapter)module);
if (module is PrincipiaPluginAdapter adapter) {
return new ExternalInterface(adapter);
}
}
return null;
}

private static void ThrowOnError(Status status) {
switch (status.error) {
case 0: return;
case 1: throw new OperationCanceledException("CANCELLED");
case 2: throw new Exception("UNKNOWN");
case 3: throw new ArgumentException("INVALID_ARGUMENT");
case 4: throw new TimeoutException("DEADLINE_EXCEEDED");
case 5: throw new KeyNotFoundException("NOT_FOUND");
case 6: throw new ArgumentException("ALREADY_EXISTS");
case 7: throw new UnauthorizedAccessException("PERMISSION_DENIED");
case 16: throw new AuthenticationException("UNAUTHENTICATED");
case 8: throw new Exception("RESOURCE_EXHAUSTED");
case 9: throw new Exception("FAILED_PRECONDITION");
case 10: throw new Exception("ABORTED");
case 11: throw new ArgumentOutOfRangeException("OUT_OF_RANGE");
case 12: throw new NotImplementedException("UNIMPLEMENTED");
case 13: throw new Exception("INTERNAL");
case 14: throw new Exception("UNAVAILABLE");
case 15: throw new Exception("DATA_LOSS");
default: throw new Exception($"Error {status.error}");
case 0:
return;
case 1:
throw new OperationCanceledException($"CANCELLED: {status.message}");
case 2:
throw new Exception($"UNKNOWN: {status.message}");
case 3:
throw new ArgumentException($"INVALID_ARGUMENT: {status.message}");
case 4:
throw new TimeoutException($"DEADLINE_EXCEEDED: {status.message}");
case 5:
throw new KeyNotFoundException($"NOT_FOUND: {status.message}");
case 6:
throw new ArgumentException($"ALREADY_EXISTS: {status.message}");
case 7:
throw new UnauthorizedAccessException(
$"PERMISSION_DENIED: {status.message}");
case 16:
throw new AuthenticationException($"UNAUTHENTICATED: {status.message}");
case 8:
throw new Exception($"RESOURCE_EXHAUSTED: {status.message}");
case 9:
throw new Exception($"FAILED_PRECONDITION: {status.message}");
case 10:
throw new Exception($"ABORTED: {status.message}");
case 11:
throw new ArgumentOutOfRangeException(
$"OUT_OF_RANGE: {status.message}");
case 12:
throw new NotImplementedException($"UNIMPLEMENTED: {status.message}");
case 13:
throw new Exception($"INTERNAL: {status.message}");
case 14:
throw new Exception($"UNAVAILABLE: {status.message}");
case 15:
throw new Exception($"DATA_LOSS: {status.message}");
default:
throw new Exception($"Error {status.error}: {status.message}");
}
}