From e75e40e4c99a7a7e55561991c860f3a92495d70f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1rton=20Balassa?= <7115274+BalassaMarton@users.noreply.github.com> Date: Thu, 5 Oct 2023 15:49:06 +0200 Subject: [PATCH] Changed AppDirectory.GetApp to throw when the app is not found (#61) Resolves #60 Co-authored-by: Brian Ingenito <28159742+bingenito@users.noreply.github.com> --- .../AppDirectoryException.cs | 30 ++++++++++++++++++ src/Fdc3.AppDirectory/AppNotFoundException.cs | 31 +++++++++++++++++++ src/Fdc3.AppDirectory/IAppDirectory.cs | 3 +- ...rganStanley.Fdc3.AppDirectory.Tests.csproj | 2 +- .../Usings.cs | 2 +- 5 files changed, 65 insertions(+), 3 deletions(-) create mode 100644 src/Fdc3.AppDirectory/AppDirectoryException.cs create mode 100644 src/Fdc3.AppDirectory/AppNotFoundException.cs diff --git a/src/Fdc3.AppDirectory/AppDirectoryException.cs b/src/Fdc3.AppDirectory/AppDirectoryException.cs new file mode 100644 index 0000000..e3435c1 --- /dev/null +++ b/src/Fdc3.AppDirectory/AppDirectoryException.cs @@ -0,0 +1,30 @@ +/* + * Morgan Stanley makes this available to you under the Apache License, + * Version 2.0 (the "License"). You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0. + * + * See the NOTICE file distributed with this work for additional information + * regarding copyright ownership. Unless required by applicable law or agreed + * to in writing, software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions + * and limitations under the License. + */ + +using System; +using System.Runtime.Serialization; + +namespace MorganStanley.Fdc3.AppDirectory +{ + /// + /// Base class for exceptions thrown by implementations + /// + public class AppDirectoryException : Exception + { + public AppDirectoryException() { } + protected AppDirectoryException(SerializationInfo info, StreamingContext context) : base(info, context) { } + public AppDirectoryException(string message) : base(message) { } + public AppDirectoryException(string message, Exception innerException) : base(message, innerException) { } + } +} diff --git a/src/Fdc3.AppDirectory/AppNotFoundException.cs b/src/Fdc3.AppDirectory/AppNotFoundException.cs new file mode 100644 index 0000000..bb6ead2 --- /dev/null +++ b/src/Fdc3.AppDirectory/AppNotFoundException.cs @@ -0,0 +1,31 @@ +/* + * Morgan Stanley makes this available to you under the Apache License, + * Version 2.0 (the "License"). You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0. + * + * See the NOTICE file distributed with this work for additional information + * regarding copyright ownership. Unless required by applicable law or agreed + * to in writing, software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions + * and limitations under the License. + */ + +using System.Runtime.Serialization; + +namespace MorganStanley.Fdc3.AppDirectory +{ + /// + /// The exception that is thrown by when the app is not found. + /// + public class AppNotFoundException : AppDirectoryException + { + public AppNotFoundException(string appId) : base($"The app with id '{appId}' was not found in the App Directory") + { + } + + public AppNotFoundException() : base("The app was not found in the App Directory") { } + protected AppNotFoundException(SerializationInfo info, StreamingContext context) : base(info, context) { } + } +} diff --git a/src/Fdc3.AppDirectory/IAppDirectory.cs b/src/Fdc3.AppDirectory/IAppDirectory.cs index b0f8e06..391ac63 100644 --- a/src/Fdc3.AppDirectory/IAppDirectory.cs +++ b/src/Fdc3.AppDirectory/IAppDirectory.cs @@ -33,6 +33,7 @@ public interface IAppDirectory /// /// Application identifier /// The application - Task GetApp(string appId); + /// The app was not found + Task GetApp(string appId); } } diff --git a/src/Tests/MorganStanley.Fdc3.AppDirectory.Tests/MorganStanley.Fdc3.AppDirectory.Tests.csproj b/src/Tests/MorganStanley.Fdc3.AppDirectory.Tests/MorganStanley.Fdc3.AppDirectory.Tests.csproj index 993b39d..3ddbcb8 100644 --- a/src/Tests/MorganStanley.Fdc3.AppDirectory.Tests/MorganStanley.Fdc3.AppDirectory.Tests.csproj +++ b/src/Tests/MorganStanley.Fdc3.AppDirectory.Tests/MorganStanley.Fdc3.AppDirectory.Tests.csproj @@ -1,4 +1,4 @@ - + net6.0 diff --git a/src/Tests/MorganStanley.Fdc3.AppDirectory.Tests/Usings.cs b/src/Tests/MorganStanley.Fdc3.AppDirectory.Tests/Usings.cs index 89c3803..b1feab6 100644 --- a/src/Tests/MorganStanley.Fdc3.AppDirectory.Tests/Usings.cs +++ b/src/Tests/MorganStanley.Fdc3.AppDirectory.Tests/Usings.cs @@ -11,4 +11,4 @@ * or implied. See the License for the specific language governing permissions * and limitations under the License. */ -global using Xunit; \ No newline at end of file +global using Xunit;