Skip to content
This repository has been archived by the owner on Nov 1, 2023. It is now read-only.

Commit

Permalink
Change some NotImplementedException to NotSupportedException (#2234)
Browse files Browse the repository at this point in the history
  • Loading branch information
Porges authored Aug 9, 2022
1 parent d15d80c commit 20faf88
Show file tree
Hide file tree
Showing 10 changed files with 20 additions and 25 deletions.
2 changes: 1 addition & 1 deletion src/ApiService/ApiService/Functions/AgentCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public Async.Task<HttpResponseData> Run(
=> _auth.CallIfAgent(req, r => r.Method switch {
"GET" => Get(req),
"DELETE" => Delete(req),
_ => throw new NotImplementedException($"HTTP Method {req.Method} is not supported for this method")
_ => throw new NotSupportedException($"HTTP Method {req.Method} is not supported for this method")
});

private async Async.Task<HttpResponseData> Get(HttpRequestData req) {
Expand Down
5 changes: 2 additions & 3 deletions src/ApiService/ApiService/OneFuzzTypes/Events.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public EventType GetEventType() {
EventNodeDeleted _ => EventType.NodeDeleted,
EventNodeCreated _ => EventType.NodeCreated,
EventJobStopped _ => EventType.JobStopped,
_ => throw new NotImplementedException(),
var x => throw new NotSupportedException($"Unknown event type: {x.GetType()}"),
};

}
Expand Down Expand Up @@ -91,8 +91,7 @@ public static Type GetTypeInfo(EventType eventType) {
EventType.NodeDeleted => typeof(EventNodeDeleted),
EventType.NodeCreated => typeof(EventNodeCreated),
EventType.JobStopped => typeof(EventJobStopped),
_ => throw new ArgumentException($"invalid input {eventType}"),

_ => throw new ArgumentException($"Unknown event type: {eventType}"),
};
}
};
Expand Down
4 changes: 2 additions & 2 deletions src/ApiService/ApiService/OneFuzzTypes/Model.cs
Original file line number Diff line number Diff line change
Expand Up @@ -788,7 +788,7 @@ public record MultipleContainer(List<SyncedDir> SyncedDirs) : IContainerDef;

public class ContainerDefConverter : JsonConverter<IContainerDef> {
public override IContainerDef? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) {
throw new NotImplementedException();
throw new NotSupportedException("reading IContainerDef is not supported");
}

public override void Write(Utf8JsonWriter writer, IContainerDef value, JsonSerializerOptions options) {
Expand All @@ -800,7 +800,7 @@ public override void Write(Utf8JsonWriter writer, IContainerDef value, JsonSeria
JsonSerializer.Serialize(writer, syncedDirs, options);
break;
default:
throw new NotImplementedException();
throw new NotSupportedException($"invalid IContainerDef type: {value.GetType()}");
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/ApiService/ApiService/onefuzzlib/Events.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public void LogEvent(BaseEvent anEvent) {

public class RemoveUserInfo : JsonConverter<UserInfo> {
public override UserInfo? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) {
throw new NotImplementedException();
throw new NotSupportedException("reading UserInfo is not supported");
}

public override void Write(Utf8JsonWriter writer, UserInfo value, JsonSerializerOptions options) {
Expand Down
6 changes: 3 additions & 3 deletions src/ApiService/ApiService/onefuzzlib/Extension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public static VMExtensionWrapper KeyVaultExtension(AzureLocation region, Keyvaul
}, _extensionSerializerOptions))
};
} else {
throw new NotImplementedException($"unsupported os {vmOs}");
throw new NotSupportedException($"unsupported os {vmOs}");
}
}

Expand Down Expand Up @@ -309,7 +309,7 @@ public async Async.Task<VMExtensionWrapper> AgentConfig(AzureLocation region, Os
return extension;
}

throw new NotImplementedException($"unsupported OS: {vmOs}");
throw new NotSupportedException($"unsupported OS: {vmOs}");
}

public async Async.Task<VMExtensionWrapper> MonitorExtension(AzureLocation region, Os vmOs) {
Expand Down Expand Up @@ -339,7 +339,7 @@ public async Async.Task<VMExtensionWrapper> MonitorExtension(AzureLocation regio
ProtectedSettings = new BinaryData(protectedExtensionSettings)
};
} else {
throw new NotImplementedException($"unsupported os: {vmOs}");
throw new NotSupportedException($"unsupported os: {vmOs}");
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/ApiService/ApiService/onefuzzlib/ReproOperations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public async Async.Task<Vm> GetVm(Repro repro, InstanceConfig config) {
var vmConfig = await taskOperations.GetReproVmConfig(task);
if (vmConfig == null) {
if (!DEFAULT_OS.ContainsKey(task.Os)) {
throw new NotImplementedException($"unsupport OS for repro {task.Os}");
throw new NotSupportedException($"unsupport OS for repro {task.Os}");
}

vmConfig = new TaskVm(
Expand Down Expand Up @@ -254,7 +254,7 @@ public async Task<OneFuzzResultVoid> BuildReproScript(Repro repro) {
var linuxCmdStdOut = $"#!/bin/bash\n{string.Format(CultureInfo.InvariantCulture, gdbFmt, "-", task.Config.Task.TargetExe, report?.InputBlob?.Name)}";
files.Add("repro-stdout.sh", linuxCmdStdOut);
break;
default: throw new NotImplementedException($"invalid task os: {task.Os}");
default: throw new NotSupportedException($"invalid task os: {task.Os}");
}

foreach (var (fileName, fileContents) in files) {
Expand Down
16 changes: 7 additions & 9 deletions src/ApiService/ApiService/onefuzzlib/Storage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,14 +128,12 @@ public IReadOnlyList<string> CorpusAccounts() {
});
}

public string GetPrimaryAccount(StorageType storageType) {
return
storageType switch {
StorageType.Corpus => GetFuzzStorage(),
StorageType.Config => GetFuncStorage(),
_ => throw new NotImplementedException(),
};
}
public string GetPrimaryAccount(StorageType storageType)
=> storageType switch {
StorageType.Corpus => GetFuzzStorage(),
StorageType.Config => GetFuncStorage(),
var x => throw new NotSupportedException($"invalid StorageType: {x}"),
};

public Async.Task<(string, string)> GetStorageAccountNameAndKey(string accountId) {
return _cache.GetOrCreateAsync<(string, string)>($"GetStorageAccountNameAndKey-{accountId}", async cacheEntry => {
Expand Down Expand Up @@ -167,7 +165,7 @@ public IReadOnlyList<string> GetAccounts(StorageType storageType) {
case StorageType.Config:
return new[] { GetFuncStorage() };
default:
throw new NotImplementedException();
throw new NotSupportedException();
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/ApiService/ApiService/onefuzzlib/VmOperations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ async Task<OneFuzzResultVoid> CreateVm(
);
break;
}
default: throw new NotImplementedException($"No support for OS type: {imageOs.OkV}");
default: throw new NotSupportedException($"No support for OS type: {imageOs.OkV}");
}

var onefuzzOwner = _context.ServiceConfiguration.OneFuzzOwner;
Expand Down
2 changes: 0 additions & 2 deletions src/ApiService/ApiService/onefuzzlib/orm/Orm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,6 @@ public StatefulOrm(ILogTracer logTracer, IOnefuzzContext context) : base(logTrac
/// </summary>
/// <param name="entity"></param>
/// <param name="MaxUpdates"></param>
/// <returns></returns>
/// <exception cref="NotImplementedException"></exception>
public async Async.Task<T?> ProcessStateUpdates(T entity, int MaxUpdates = 5) {
for (int i = 0; i < MaxUpdates; i++) {
var state = entity.State;
Expand Down
2 changes: 1 addition & 1 deletion src/ApiService/IntegrationTests/Fakes/TestContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public Async.Task InsertAll(params EntityBase[] objs)
Job j => JobOperations.Insert(j),
NodeTasks nt => NodeTasksOperations.Insert(nt),
InstanceConfig ic => ConfigOperations.Insert(ic),
_ => throw new NotImplementedException($"Need to add an TestContext.InsertAll case for {x.GetType()} entities"),
_ => throw new NotSupportedException($"You will need to add an TestContext.InsertAll case for {x.GetType()} entities"),
}));

// Implementations:
Expand Down

0 comments on commit 20faf88

Please sign in to comment.