diff --git a/src/Managing.Api/Controllers/DataController.cs b/src/Managing.Api/Controllers/DataController.cs
index 4e4b6dde..c9e79146 100644
--- a/src/Managing.Api/Controllers/DataController.cs
+++ b/src/Managing.Api/Controllers/DataController.cs
@@ -47,6 +47,7 @@ public class DataController : ControllerBase
/// Service for account management.
/// Service for caching data.
/// Service for statistical analysis.
+ /// Service for agents
/// SignalR hub context for real-time communication.
/// Mediator for handling commands and queries.
/// Service for trading operations.
@@ -451,6 +452,11 @@ public class DataController : ControllerBase
[HttpGet("GetUserStrategies")]
public async Task>> GetUserStrategies(string agentName)
{
+ if (string.IsNullOrEmpty(agentName))
+ {
+ return BadRequest("Agent name cannot be null or empty.");
+ }
+
// Get all strategies for the specified user
var userStrategies = await _mediator.Send(new GetUserStrategiesCommand(agentName));
@@ -476,6 +482,16 @@ public class DataController : ControllerBase
[HttpGet("GetUserStrategy")]
public async Task> GetUserStrategy(string agentName, string strategyName)
{
+ if (string.IsNullOrEmpty(agentName))
+ {
+ return BadRequest("Agent name cannot be null or empty.");
+ }
+
+ if (string.IsNullOrEmpty(strategyName))
+ {
+ return BadRequest("Strategy name cannot be null or empty.");
+ }
+
// Get the specific strategy for the user
var strategy = await _mediator.Send(new GetUserStrategyCommand(agentName, strategyName));
diff --git a/src/Managing.Application/Users/UserService.cs b/src/Managing.Application/Users/UserService.cs
index fcc23557..6d838b9b 100644
--- a/src/Managing.Application/Users/UserService.cs
+++ b/src/Managing.Application/Users/UserService.cs
@@ -56,14 +56,12 @@ public class UserService : IUserService
if (!_authorizedAddresses.Any(a => string.Equals(a, recoveredAddress, StringComparison.OrdinalIgnoreCase)))
{
- _logger.LogWarning($"Address {recoveredAddress} not authorized");
- throw new Exception("Address not authorized");
+ throw new Exception($"Address {recoveredAddress} not authorized");
}
if (recoveredAddress == null || !recoveredAddress.Equals(address))
{
- _logger.LogWarning($"Address {recoveredAddress} not corresponding");
- throw new Exception("Address not corresponding");
+ throw new Exception($"Address {recoveredAddress} not corresponding");
}
// Check if account exist
@@ -72,7 +70,7 @@ public class UserService : IUserService
if (user != null)
{
if (!user.Name.Equals(name))
- throw new Exception("Name not corresponding");
+ throw new Exception("Name not corresponding to user " + name);
// User and account found
user.Accounts = _accountService.GetAccountsByUser(user).ToList();
@@ -82,7 +80,7 @@ public class UserService : IUserService
if (account == null)
{
- throw new Exception("Account not found");
+ throw new Exception("Account not found for address " + recoveredAddress);
}
return user;