Skip to content

Commit

Permalink
Changed AppDirectory.GetApp to throw when the app is not found
Browse files Browse the repository at this point in the history
Resolves #60
  • Loading branch information
BalassaMarton committed Oct 5, 2023
1 parent ced0273 commit cba113e
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 3 deletions.
30 changes: 30 additions & 0 deletions src/Fdc3.AppDirectory/AppDirectoryException.cs
Original file line number Diff line number Diff line change
@@ -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
{
/// <summary>
/// Base class for exceptions thrown by <see cref="IAppDirectory"/> implementations
/// </summary>
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) { }
}
}
31 changes: 31 additions & 0 deletions src/Fdc3.AppDirectory/AppNotFoundException.cs
Original file line number Diff line number Diff line change
@@ -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
{
/// <summary>
/// The exception that is thrown by <see cref="IAppDirectory.GetApp"/> when the app is not found.
/// </summary>
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) { }
}
}
3 changes: 2 additions & 1 deletion src/Fdc3.AppDirectory/IAppDirectory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public interface IAppDirectory
/// </summary>
/// <param name="appId">Application identifier</param>
/// <returns>The application</returns>
Task<Fdc3App?> GetApp(string appId);
/// <exception cref="AppNotFoundException">The app was not found</exception>
Task<Fdc3App> GetApp(string appId);
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
Expand Down
3 changes: 2 additions & 1 deletion src/Tests/MorganStanley.Fdc3.AppDirectory.Tests/Usings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@
* or implied. See the License for the specific language governing permissions
* and limitations under the License.
*/
global using Xunit;
global using Xunit;
global using Moq;

Check failure on line 15 in src/Tests/MorganStanley.Fdc3.AppDirectory.Tests/Usings.cs

View workflow job for this annotation

GitHub Actions / build / build

The type or namespace name 'Moq' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 15 in src/Tests/MorganStanley.Fdc3.AppDirectory.Tests/Usings.cs

View workflow job for this annotation

GitHub Actions / build / build

The type or namespace name 'Moq' could not be found (are you missing a using directive or an assembly reference?)

0 comments on commit cba113e

Please sign in to comment.