Merge branch 'master' of ssh://repo.hottis.de:2922/wolutator/genericdatabaseapiservice

This commit is contained in:
2021-12-08 14:54:17 +01:00
2 changed files with 17 additions and 5 deletions

View File

@ -28,6 +28,9 @@ namespace com.krohne.genericdatabaseapiservice.Services {
public string Name { get; set; }
}
public class DbInfoServiceException : Exception {}
public class UnknownDatabaseTagException: DbInfoServiceException {}
public interface IDbInfoService {
DbInfoObject GetInfoByTag(string tag);
string GetInfoStringByTag(string tag);
@ -44,16 +47,20 @@ namespace com.krohne.genericdatabaseapiservice.Services {
}
public DbInfoObject GetInfoByTag(string tag) {
return DbInfos[tag];
try {
return DbInfos[tag];
} catch (KeyNotFoundException) {
throw new UnknownDatabaseTagException();
}
}
public string GetInfoStringByTag(string tag) {
return String.Format(
"Server={0};User ID={1};Password={2};Database={3}",
DbInfos[tag].Host,
DbInfos[tag].User,
DbInfos[tag].Password,
DbInfos[tag].Name);
GetInfoByTag(tag).Host,
GetInfoByTag(tag).User,
GetInfoByTag(tag).Password,
GetInfoByTag(tag).Name);
}
}

View File

@ -15,6 +15,11 @@ Exceptions:
ServiceErrorCode: 10003
ErrorMessage: unsupported data type, review the DbService implementation
ErrorInfoURL: https://google.com
- Exception: UnknownDatabaseTagException
ErrorCode: 500
ServiceErrorCode: 10004
ErrorMessage: the database tag mentioned in the API spec is not configured on the server, review the server configuration
ErrorInfoURL: https://google.com
# Make sure "Exception: Exception" is the last entry in the list
- Exception: Exception
ErrorCode: 500