unknown database tag exception introduced
This commit is contained in:
17
DbService.cs
17
DbService.cs
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
Reference in New Issue
Block a user