debugging
This commit is contained in:
parent
b5d20b185f
commit
959b36760a
17
DbService.cs
17
DbService.cs
@ -14,8 +14,9 @@ namespace de.hottis.genericdatabaseapiservice.Services {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public class DbServiceException : Exception {}
|
public class DbServiceException : Exception {}
|
||||||
public class NotDataFoundException : DbServiceException {}
|
public class NoDataFoundException : DbServiceException {}
|
||||||
public class TooMuchDataFoundException : DbServiceException {}
|
public class TooMuchDataFoundException : DbServiceException {}
|
||||||
|
public class UnsupportedDataTypeException: DbServiceException {}
|
||||||
|
|
||||||
public class DbService : IDbService {
|
public class DbService : IDbService {
|
||||||
private readonly IConfiguration Configuration;
|
private readonly IConfiguration Configuration;
|
||||||
@ -68,11 +69,15 @@ namespace de.hottis.genericdatabaseapiservice.Services {
|
|||||||
propertyInfo.SetValue(item, null);
|
propertyInfo.SetValue(item, null);
|
||||||
Console.WriteLine("Output Value: null");
|
Console.WriteLine("Output Value: null");
|
||||||
} else if (propertyInfo.PropertyType == typeof(System.String)) {
|
} else if (propertyInfo.PropertyType == typeof(System.String)) {
|
||||||
propertyInfo.SetValue(item, reader.GetString(ordinal));
|
var value = reader.GetString(ordinal);
|
||||||
Console.WriteLine("Output Value:{0}", reader.GetString(ordinal));
|
propertyInfo.SetValue(item, value);
|
||||||
|
Console.WriteLine("Output Value:{0}", value);
|
||||||
} else if (propertyInfo.PropertyType == typeof(System.Int32)) {
|
} else if (propertyInfo.PropertyType == typeof(System.Int32)) {
|
||||||
propertyInfo.SetValue(item, reader.GetInt32(ordinal));
|
var value = reader.GetInt32(ordinal);
|
||||||
Console.WriteLine("Output Value:{0}", reader.GetInt32(ordinal));
|
propertyInfo.SetValue(item, value);
|
||||||
|
Console.WriteLine("Output Value:{0}", value);
|
||||||
|
} else {
|
||||||
|
throw new UnsupportedDataTypeException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
itemList.Add(item);
|
itemList.Add(item);
|
||||||
@ -82,7 +87,7 @@ namespace de.hottis.genericdatabaseapiservice.Services {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (itemList.Count == 0) {
|
if (itemList.Count == 0) {
|
||||||
throw new NotDataFoundException();
|
throw new NoDataFoundException();
|
||||||
}
|
}
|
||||||
if (justOne && itemList.Count > 1) {
|
if (justOne && itemList.Count > 1) {
|
||||||
throw new TooMuchDataFoundException();
|
throw new TooMuchDataFoundException();
|
||||||
|
@ -5,7 +5,7 @@ info:
|
|||||||
version: "2.0.0"
|
version: "2.0.0"
|
||||||
|
|
||||||
paths:
|
paths:
|
||||||
/pdb/v2/test1:
|
# /pdb/v2/test1:
|
||||||
# post:
|
# post:
|
||||||
# tags: [ "Regular" ]
|
# tags: [ "Regular" ]
|
||||||
# operationId: Regular.test1insert
|
# operationId: Regular.test1insert
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
# ONLY USE THE ERRORCODES 400 and 500 HERE
|
# ONLY USE THE ERRORCODES 400 and 500 HERE
|
||||||
Exceptions:
|
Exceptions:
|
||||||
- Exception: NotDataFoundException
|
- Exception: NoDataFoundException
|
||||||
ErrorCode: 400
|
ErrorCode: 400
|
||||||
ServiceErrorCode: 10001
|
ServiceErrorCode: 10001
|
||||||
ErrorMessage: item not found
|
ErrorMessage: item not found
|
||||||
@ -10,6 +10,11 @@ Exceptions:
|
|||||||
ServiceErrorCode: 10002
|
ServiceErrorCode: 10002
|
||||||
ErrorMessage: too many items found
|
ErrorMessage: too many items found
|
||||||
ErrorInfoURL: https://google.com
|
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
|
# Make sure "Exception: Exception" is the last entry in the list
|
||||||
- Exception: Exception
|
- Exception: Exception
|
||||||
ErrorCode: 500
|
ErrorCode: 500
|
||||||
|
Loading…
x
Reference in New Issue
Block a user