better exceptions

This commit is contained in:
Wolfgang Hottgenroth 2021-12-15 16:46:40 +01:00
parent 30f4abc024
commit 61bb8cfc54

View File

@ -138,6 +138,7 @@ namespace com.krohne.genericdatabaseapiservice.Services {
var sep = "";
foreach (var x in p1) {
if (! (x is int || x is long)) {
Logger.LogError("Parameter binding by string replacement is for security reasons only allowed for numbers");
throw new StringReplacementNotAllowedException();
}
Logger.LogInformation("x: {0}", x);
@ -149,6 +150,7 @@ namespace com.krohne.genericdatabaseapiservice.Services {
Logger.LogInformation("Input Value: p3:{0} typ:{1} isList:{2}", p3, typ, isList);
if (bindingByStringReplacement) {
if (commandTextSet) {
Logger.LogError("Parameter bindung by string replacement is only supported for a single parameter");
throw new StringReplacementNotAllowedException("string replacement only allowed for numeric parameters");
}
var processedStatement = selectStatement.Replace(String.Format("@{0}", dma.Name), p3);
@ -160,6 +162,7 @@ namespace com.krohne.genericdatabaseapiservice.Services {
}
} else {
if (bindingByStringReplacement) {
Logger.LogError("Parameter binding by string replacement is only supported for array parameters");
throw new StringReplacementNotAllowedException("string replacement only allowed to handle lists of parameters");
}
Logger.LogInformation("Input Value: {0} {1} {2}", value, typ, isList);
@ -205,6 +208,7 @@ namespace com.krohne.genericdatabaseapiservice.Services {
propertyInfo.SetValue(item, value);
Logger.LogInformation("Output Value:{0}", value);
} else {
Logger.LogError("Unsupported data type {0}", propertyInfo.PropertyType);
throw new UnsupportedDataTypeException(String.Format("{0}", propertyInfo.PropertyType));
}
}