debugging

This commit is contained in:
Wolfgang Ludger Hottgenroth 2021-12-02 15:57:58 +01:00
parent b5d20b185f
commit 959b36760a
Signed by: wn
GPG Key ID: 6C1E5E531E0D5D7F
3 changed files with 18 additions and 8 deletions

View File

@ -14,8 +14,9 @@ namespace de.hottis.genericdatabaseapiservice.Services {
}
public class DbServiceException : Exception {}
public class NotDataFoundException : DbServiceException {}
public class NoDataFoundException : DbServiceException {}
public class TooMuchDataFoundException : DbServiceException {}
public class UnsupportedDataTypeException: DbServiceException {}
public class DbService : IDbService {
private readonly IConfiguration Configuration;
@ -68,11 +69,15 @@ namespace de.hottis.genericdatabaseapiservice.Services {
propertyInfo.SetValue(item, null);
Console.WriteLine("Output Value: null");
} else if (propertyInfo.PropertyType == typeof(System.String)) {
propertyInfo.SetValue(item, reader.GetString(ordinal));
Console.WriteLine("Output Value:{0}", reader.GetString(ordinal));
var value = reader.GetString(ordinal);
propertyInfo.SetValue(item, value);
Console.WriteLine("Output Value:{0}", value);
} else if (propertyInfo.PropertyType == typeof(System.Int32)) {
propertyInfo.SetValue(item, reader.GetInt32(ordinal));
Console.WriteLine("Output Value:{0}", reader.GetInt32(ordinal));
var value = reader.GetInt32(ordinal);
propertyInfo.SetValue(item, value);
Console.WriteLine("Output Value:{0}", value);
} else {
throw new UnsupportedDataTypeException();
}
}
itemList.Add(item);
@ -82,7 +87,7 @@ namespace de.hottis.genericdatabaseapiservice.Services {
}
if (itemList.Count == 0) {
throw new NotDataFoundException();
throw new NoDataFoundException();
}
if (justOne && itemList.Count > 1) {
throw new TooMuchDataFoundException();

View File

@ -5,7 +5,7 @@ info:
version: "2.0.0"
paths:
/pdb/v2/test1:
# /pdb/v2/test1:
# post:
# tags: [ "Regular" ]
# operationId: Regular.test1insert

View File

@ -1,6 +1,6 @@
# ONLY USE THE ERRORCODES 400 and 500 HERE
Exceptions:
- Exception: NotDataFoundException
- Exception: NoDataFoundException
ErrorCode: 400
ServiceErrorCode: 10001
ErrorMessage: item not found
@ -10,6 +10,11 @@ Exceptions:
ServiceErrorCode: 10002
ErrorMessage: too many items found
ErrorInfoURL: https://google.com
- Exception: UnsupportedDataTypeException
ErrorCode: 500
ServiceErrorCode: 10003
ErrorMessage: unsupported data type, review the DbService implementation
ErrorInfoURL: https://google.com
# Make sure "Exception: Exception" is the last entry in the list
- Exception: Exception
ErrorCode: 500