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);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user