Permalink
Browse files

Remove ExceptionBuilder.Throw methods

  • Loading branch information...
f00f authored and jangernert committed Nov 13, 2018
1 parent 2d79e2e commit d55f2a94e80266b662408f83b6fb5c236751b192
@@ -91,8 +91,7 @@ public int DeviceChannel
var desc = DeviceChannelDesc;
if (!desc.IsValid(value))
{
ExceptionBuilder.Throw(typeof(ArgumentOutOfRangeException), this, "error_setParameter", String.Format("The device channel must be between {0} and {1}.", desc.Min, desc.Max));
return;
throw ExceptionBuilder.Build(typeof(ArgumentOutOfRangeException), Name, "error_setParameter", String.Format("The device channel must be between {0} and {1}.", desc.Min, desc.Max));
}
if (!IsConnected)
@@ -131,8 +130,7 @@ public float Exposure
var desc = ExposureDesc;
if (!desc.IsValid(value))
{
ExceptionBuilder.Throw(typeof(ArgumentOutOfRangeException), this, "error_setParameter", String.Format("The exposure time must be between {0} and {1} ms.", desc.Min, desc.Max));
return;
throw ExceptionBuilder.Build(typeof(ArgumentOutOfRangeException), Name, "error_setParameter", String.Format("The exposure time must be between {0} and {1} ms.", desc.Min, desc.Max));
}
exposureMilliseconds = value;
@@ -221,8 +221,7 @@ protected override CameraImage CalcChannelImpl(string channelName)
return irImage;
}
ExceptionBuilder.Throw(typeof(ArgumentException), this, "error_invalidChannelName", channelName);
return null;
throw ExceptionBuilder.Build(typeof(ArgumentException), Name, "error_invalidChannelName", channelName);
}
#endregion
@@ -127,7 +127,7 @@ protected override void ConnectImpl()
if (deviceInfo.Count == 0)
{
log.Error(Name + ": No devices found.");
ExceptionBuilder.Throw(typeof(ConnectionFailedException), this, "No devices found.");
throw ExceptionBuilder.Build(typeof(ConnectionFailedException), Name, "No devices found.");
}
int deviceIdx;
@@ -145,7 +145,7 @@ protected override void ConnectImpl()
if (deviceIdx >= deviceInfo.Count)
{
log.Error("Failed to find Intel Real Sense R200 camera!");
ExceptionBuilder.Throw(typeof(ConnectionFailedException), this, "No R200 found!");
throw ExceptionBuilder.Build(typeof(ConnectionFailedException), Name, "No R200 found!");
}
ScanForProfiles(deviceIdx);
@@ -166,7 +166,7 @@ protected override void ConnectImpl()
if (retStat < pxcmStatus.PXCM_STATUS_NO_ERROR)
{
log.Error(Name + ": Init() failed.");
ExceptionBuilder.Throw(typeof(ConnectionFailedException), this, "Failed to Initialize Real Sense SDK");
throw ExceptionBuilder.Build(typeof(ConnectionFailedException), Name, "Failed to Initialize Real Sense SDK");
}
pp.captureManager.device.ResetProperties(PXCMCapture.StreamType.STREAM_TYPE_ANY);
@@ -293,8 +293,7 @@ protected override CameraImage CalcChannelImpl(string channelName)
return colorImage;
}
ExceptionBuilder.Throw(typeof(ArgumentException), this, "error_invalidChannelName", channelName);
return null;
throw ExceptionBuilder.Build(typeof(ArgumentException), Name, "error_invalidChannelName", channelName);
}
public override RigidBodyTransformation GetExtrinsics(string channelFromName, string channelToName)

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -143,7 +143,7 @@ protected override void ConnectImpl()
}
else
{
ExceptionBuilder.Throw(typeof(ConnectionFailedException), this, "error_connectionFailed", "CoLa (binary) telegram subscription failed");
throw ExceptionBuilder.Build(typeof(ConnectionFailedException), Name, "error_connectionFailed", "CoLa (binary) telegram subscription failed");
}
}
catch
@@ -178,7 +178,7 @@ protected override void ConnectImpl()
catch (Exception foreignException)
{
// Wrap and Throw other exceptions encountered during Connection
ExceptionBuilder.Throw(typeof(ConnectionFailedException), this, foreignException);
throw ExceptionBuilder.Build(typeof(ConnectionFailedException), Name, foreignException.Message, foreignException);
}
}
@@ -282,7 +282,7 @@ protected override void UpdateImpl()
catch (Exception foreignException)
{
// Wrap and Throw other exceptions encountered during Connection
ExceptionBuilder.Throw(typeof(ImageAcquisitionFailedException), this, foreignException);
throw ExceptionBuilder.Build(typeof(ImageAcquisitionFailedException), Name, foreignException.Message, foreignException);
}
}
@@ -350,7 +350,7 @@ protected override CameraImage CalcChannelImpl(string channelName)
string msg = $"{Name}: Invalid channelname: {channelName}";
log.Error(msg);
throw ExceptionBuilder.Build(typeof(InvalidOperationException), this, msg);
throw ExceptionBuilder.Build(typeof(InvalidOperationException), Name, msg);
}
#region Channel Information
@@ -200,7 +200,7 @@ protected override void ConnectImpl()
{
string msg = string.Format("IP address is not set. It must be set before connecting.");
log.Error(msg);
ExceptionBuilder.Throw(typeof(Exceptions.ConnectionFailedException), this, "error_connectionFailed", msg);
throw ExceptionBuilder.Build(typeof(ConnectionFailedException), Name, "error_connectionFailed", msg);
}
device = new Device(ipAddress, this, log);
@@ -31,8 +31,7 @@ void TIVoxel::ConnectImpl()
size_t numDevices = devices.size();
if (numDevices == 0)
{
ExceptionBuilder::Throw(MetriCam2::Exceptions::ConnectionFailedException::typeid, this, "error_connectionFailed", "No devices found.");
return;
throw ExceptionBuilder::Build(MetriCam2::Exceptions::ConnectionFailedException::typeid, Name, "error_connectionFailed", "No devices found.");
}
Voxel::DevicePtr toConnect;
for (int i = 0; i < numDevices; i++)
@@ -59,8 +58,7 @@ void TIVoxel::ConnectImpl()
}
if (cam == NULL || !(cam->isInitialized()))
{
ExceptionBuilder::Throw(MetriCam2::Exceptions::ConnectionFailedException::typeid, this, "error_connectionFailed", "Failed to open camera.");
return;
throw ExceptionBuilder::Build(MetriCam2::Exceptions::ConnectionFailedException::typeid, Name, "error_connectionFailed", "Failed to open camera.");
}
this->SerialNumber = marshal_as<String^>((device)->serialNumber());
@@ -97,13 +95,9 @@ void TIVoxel::ConnectImpl()
{
log->Error("Could not register callback.");
IsConnected = false;
ExceptionBuilder::Throw(MetriCam2::Exceptions::ConnectionFailedException::typeid, this, "error_connectionFailed", "Could not register callback.");
return;
}
else
{
log->Debug("Callback registered successfully.");
throw ExceptionBuilder::Build(MetriCam2::Exceptions::ConnectionFailedException::typeid, Name, "error_connectionFailed", "Could not register callback.");
}
log->Debug("Callback registered successfully.");
cam->start();
ActivateChannel(CHANNEL_NAME_AMPLITUDE);
@@ -145,8 +139,7 @@ void TIVoxel::ConnectImpl()
{
// this exception was unexpected, log it and throw our own one
log->Error(ex->Message);
ExceptionBuilder::Throw(MetriCam2::Exceptions::ConnectionFailedException::typeid, this, "error_connectionFailed", "Unexpected error: " + ex->Message);
return;
throw ExceptionBuilder::Build(MetriCam2::Exceptions::ConnectionFailedException::typeid, Name, "error_connectionFailed", "Unexpected error: " + ex->Message);
}
finally
{
@@ -231,8 +224,7 @@ Object^ TIVoxel::GetParameterByName(String^ name)
if (!boolParam->get(value, true))
{
ExceptionBuilder::Throw(MetriCam2::Exceptions::ParameterNotSupportedException::typeid, this, "error_getParameter", "Could not convert value of parameter " + name + ".");
return false;
throw ExceptionBuilder::Build(MetriCam2::Exceptions::ParameterNotSupportedException::typeid, Name, "error_getParameter", "Could not convert value of parameter " + name + ".");
}
log->Debug(name + " = " + value.ToString());
@@ -253,8 +245,7 @@ Object^ TIVoxel::GetParameterByName(String^ name)
int value;
if (!intParam->get(value, true))
{
ExceptionBuilder::Throw(MetriCam2::Exceptions::ParameterNotSupportedException::typeid, this, "error_getParameter", "Could not convert value of parameter " + name + ".");
return false;
throw ExceptionBuilder::Build(MetriCam2::Exceptions::ParameterNotSupportedException::typeid, Name, "error_getParameter", "Could not convert value of parameter " + name + ".");
}
String^ unit = msclr::interop::marshal_as<String^>(intParam->unit());
@@ -267,8 +258,7 @@ Object^ TIVoxel::GetParameterByName(String^ name)
uint value;
if (!uintParam->get(value, true))
{
ExceptionBuilder::Throw(MetriCam2::Exceptions::ParameterNotSupportedException::typeid, this, "error_getParameter", "Could not convert value of parameter " + name + ".");
return false;
throw ExceptionBuilder::Build(MetriCam2::Exceptions::ParameterNotSupportedException::typeid, Name, "error_getParameter", "Could not convert value of parameter " + name + ".");
}
String^ unit = msclr::interop::marshal_as<String^>(uintParam->unit());
@@ -281,8 +271,7 @@ Object^ TIVoxel::GetParameterByName(String^ name)
float value;
if (!floatParam->get(value, true))
{
ExceptionBuilder::Throw(MetriCam2::Exceptions::ParameterNotSupportedException::typeid, this, "error_getParameter", "Could not convert value of parameter " + name + ".");
return false;
throw ExceptionBuilder::Build(MetriCam2::Exceptions::ParameterNotSupportedException::typeid, Name, "error_getParameter", "Could not convert value of parameter " + name + ".");
}
String^ unit = msclr::interop::marshal_as<String^>(floatParam->unit());
@@ -295,8 +284,7 @@ Object^ TIVoxel::GetParameterByName(String^ name)
int value;
if (!enumParam->get(value, true))
{
ExceptionBuilder::Throw(MetriCam2::Exceptions::ParameterNotSupportedException::typeid, this, "error_getParameter", "Could not convert value of parameter " + name + ".");
return false;
throw ExceptionBuilder::Build(MetriCam2::Exceptions::ParameterNotSupportedException::typeid, Name, "error_getParameter", "Could not convert value of parameter " + name + ".");
}
log->Debug(name + " = " + value.ToString());
@@ -313,8 +301,7 @@ Object^ TIVoxel::GetParameterByName(String^ name)
}
else
{
ExceptionBuilder::Throw(MetriCam2::Exceptions::ParameterNotSupportedException::typeid, this, "error_getParameter", "Could not convert value of parameter " + name + ". Unsupported parameter type.");
return false;
throw ExceptionBuilder::Build(MetriCam2::Exceptions::ParameterNotSupportedException::typeid, Name, "error_getParameter", "Could not convert value of parameter " + name + ". Unsupported parameter type.");
}
}
@@ -343,7 +330,7 @@ void TIVoxel::SetParameterByName(String^ name, Object^ value)
bool val = (bool)value;
if (!boolParam->set(val))
{
ExceptionBuilder::Throw(MetriCam2::Exceptions::ParameterNotSupportedException::typeid, this, "Could not set parameter " + name + " to " + val + ".");
throw ExceptionBuilder::Build(MetriCam2::Exceptions::ParameterNotSupportedException::typeid, Name, "Could not set parameter " + name + " to " + val + ".");
}
return;
}
@@ -352,7 +339,7 @@ void TIVoxel::SetParameterByName(String^ name, Object^ value)
int val = (int)value;
if (!intParam->set(val))
{
ExceptionBuilder::Throw(MetriCam2::Exceptions::ParameterNotSupportedException::typeid, this, "Could not set parameter " + name + " to " + val + ".");
throw ExceptionBuilder::Build(MetriCam2::Exceptions::ParameterNotSupportedException::typeid, Name, "Could not set parameter " + name + " to " + val + ".");
}
return;
}
@@ -361,7 +348,7 @@ void TIVoxel::SetParameterByName(String^ name, Object^ value)
uint val = (uint)value;
if (!uintParam->set(val))
{
ExceptionBuilder::Throw(MetriCam2::Exceptions::ParameterNotSupportedException::typeid, this, "Could not set parameter " + name + " to " + val + ".");
throw ExceptionBuilder::Build(MetriCam2::Exceptions::ParameterNotSupportedException::typeid, Name, "Could not set parameter " + name + " to " + val + ".");
}
return;
}
@@ -370,7 +357,7 @@ void TIVoxel::SetParameterByName(String^ name, Object^ value)
float val = (float)value;
if (!floatParam->set(val))
{
ExceptionBuilder::Throw(MetriCam2::Exceptions::ParameterNotSupportedException::typeid, this, "Could not set parameter " + name + " to " + val + ".");
throw ExceptionBuilder::Build(MetriCam2::Exceptions::ParameterNotSupportedException::typeid, Name, "Could not set parameter " + name + " to " + val + ".");
}
return;
}
@@ -379,12 +366,12 @@ void TIVoxel::SetParameterByName(String^ name, Object^ value)
int val = (System::UInt32)value;
if (!enumParam->set(val))
{
ExceptionBuilder::Throw(MetriCam2::Exceptions::ParameterNotSupportedException::typeid, this, "Could not set parameter " + name + " to " + val + ".");
throw ExceptionBuilder::Build(MetriCam2::Exceptions::ParameterNotSupportedException::typeid, Name, "Could not set parameter " + name + " to " + val + ".");
}
return;
}
ExceptionBuilder::Throw(MetriCam2::Exceptions::ParameterNotSupportedException::typeid, this, "error_setParameter", "Could not set parameter " + name + ". Parameter type is unsupported.");
throw ExceptionBuilder::Build(MetriCam2::Exceptions::ParameterNotSupportedException::typeid, Name, "error_setParameter", "Could not set parameter " + name + ". Parameter type is unsupported.");
return;
}
@@ -938,7 +925,7 @@ void TIVoxel::SetIntegrationDutyCycle(uint val)
if (regOverflow)
{
ExceptionBuilder::Throw(InvalidOperationException::typeid, this, "error_setParameter", "Integration Duty Cycle beyond limit. Change it to a lower value.");
throw ExceptionBuilder::Build(InvalidOperationException::typeid, Name, "error_setParameter", "Integration Duty Cycle beyond limit. Change it to a lower value.");
}
}
@@ -1125,7 +1112,7 @@ void TIVoxel::SetQuads(unsigned int val)
{
if (val != 4 && val != 6)
{
ExceptionBuilder::Throw(InvalidOperationException::typeid, this, "error_setParameter", "Quads must be 4 or 6!");
throw ExceptionBuilder::Build(InvalidOperationException::typeid, Name, "error_setParameter", "Quads must be 4 or 6!");
}
System::Threading::Monitor::Enter(settingsLock);
@@ -1147,7 +1134,7 @@ void TIVoxel::SetSubFrames(uint val)
{
if (val != 1 && val != 2 && val != 4)
{
ExceptionBuilder::Throw(InvalidOperationException::typeid, this, "error_setParameter", "Subframes must be 1, 2 or 4!");
throw ExceptionBuilder::Build(InvalidOperationException::typeid, Name, "error_setParameter", "Subframes must be 1, 2 or 4!");
}
System::Threading::Monitor::Enter(settingsLock);
@@ -446,7 +446,7 @@ protected override void ConnectImpl()
deviceID = GetDeviceIDbySerial();
if (deviceID <= 0)
{
ExceptionBuilder.Throw(typeof(MetriCam2.Exceptions.ConnectionFailedException), Name, "error_connectionFailed", String.Format("Could not connect to camera with the serial number {0}.", SerialNumber));
throw ExceptionBuilder.Build(typeof(Exceptions.ConnectionFailedException), Name, "error_connectionFailed", String.Format("Could not connect to camera with the serial number {0}.", SerialNumber));
}
deviceID |= uEyeDriverWrapper.IS_USE_DEVICE_ID;
}
@@ -456,13 +456,13 @@ protected override void ConnectImpl()
if (nRet == uEyeDriverWrapper.IS_STARTER_FW_UPLOAD_NEEDED)
{
// TODO: Driver allows upload of new firmware. Check IDS docs for sample code.
ExceptionBuilder.Throw(typeof(MetriCam2.Exceptions.ConnectionFailedException), Name, "error_connectionFailed", "This camera requires a new firmware. Please install with the appropriate tool from the camera vendor.");
throw ExceptionBuilder.Build(typeof(Exceptions.ConnectionFailedException), Name, "error_connectionFailed", "This camera requires a new firmware. Please install with the appropriate tool from the camera vendor.");
}
if (nRet != uEyeDriverWrapper.IS_SUCCESS)
{
ExceptionBuilder.Throw(typeof(MetriCam2.Exceptions.ConnectionFailedException), Name, "error_connectionFailed");
throw ExceptionBuilder.Build(typeof(Exceptions.ConnectionFailedException), Name, "error_connectionFailed");
}
@@ -651,8 +651,7 @@ protected override CameraImage CalcChannelImpl(string channelName)
case ChannelNames.Intensity:
return CalcIntensity();
default:
ExceptionBuilder.Throw(typeof(ArgumentException), this, "error_invalidChannelName", channelName);
return null;
throw ExceptionBuilder.Build(typeof(ArgumentException), Name, "error_invalidChannelName", channelName);
}
}
#endregion
@@ -488,7 +488,7 @@ protected override void ConnectImpl()
{
_edit.StopEditingApplication();
SetConfigurationMode(Mode.Run);
ExceptionBuilder.Throw(typeof(ArgumentException), this, "error_invalidApplicationId", _applicationId.ToString());
throw ExceptionBuilder.Build(typeof(ArgumentException), Name, "error_invalidApplicationId", _applicationId.ToString());
}
}
@@ -665,8 +665,7 @@ protected override CameraImage CalcChannelImpl(string channelName)
return CalcRawConfidanceImage();
}
}
ExceptionBuilder.Throw(typeof(ArgumentException), this, "error_invalidChannelName", channelName);
return null;
throw ExceptionBuilder.Build(typeof(ArgumentException), Name, "error_invalidChannelName", channelName);
}
#endregion
#endregion
Oops, something went wrong.

0 comments on commit d55f2a9

Please sign in to comment.