Added Elmah, Serilog to Server, improved logging
This commit is contained in:
@@ -21,8 +21,16 @@ public class SearchdomainController : ControllerBase
|
||||
[HttpGet("List")]
|
||||
public ActionResult<SearchdomainListResults> List()
|
||||
{
|
||||
var results = _domainManager.ListSearchdomains()
|
||||
?? throw new Exception("Unable to list searchdomains");
|
||||
List<string> results;
|
||||
try
|
||||
{
|
||||
results = _domainManager.ListSearchdomains();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
_logger.LogError("Unable to list searchdomains");
|
||||
throw;
|
||||
}
|
||||
SearchdomainListResults searchdomainListResults = new() {Searchdomains = results};
|
||||
return Ok(searchdomainListResults);
|
||||
}
|
||||
@@ -36,7 +44,8 @@ public class SearchdomainController : ControllerBase
|
||||
return Ok(new SearchdomainCreateResults(){Id = id, Success = true});
|
||||
} catch (Exception)
|
||||
{
|
||||
return Ok(new SearchdomainCreateResults(){Id = null, Success = false});
|
||||
_logger.LogError("Unable to create Searchdomain {searchdomain}", [searchdomain]);
|
||||
return Ok(new SearchdomainCreateResults() { Id = null, Success = false });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,9 +58,9 @@ public class SearchdomainController : ControllerBase
|
||||
{
|
||||
success = true;
|
||||
deletedEntries = _domainManager.DeleteSearchdomain(searchdomain);
|
||||
} catch (Exception ex)
|
||||
} catch (Exception)
|
||||
{
|
||||
Console.WriteLine(ex);
|
||||
_logger.LogError("Unable to delete searchdomain {searchdomain}", [searchdomain]);
|
||||
success = false;
|
||||
deletedEntries = 0;
|
||||
}
|
||||
@@ -73,7 +82,8 @@ public class SearchdomainController : ControllerBase
|
||||
searchdomain_.helper.ExecuteSQLNonQuery("UPDATE searchdomain set name = @name, settings = @settings WHERE id = @id", parameters);
|
||||
} catch (Exception)
|
||||
{
|
||||
return Ok(new SearchdomainUpdateResults(){Success = false});
|
||||
_logger.LogError("Unable to update searchdomain {searchdomain}", [searchdomain]);
|
||||
return Ok(new SearchdomainUpdateResults() { Success = false });
|
||||
}
|
||||
return Ok(new SearchdomainUpdateResults(){Success = true});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user