how to get error code from exception in c#
try {
// some operation causing an exception
}
catch (SqlException e) {
if (e.ErrorCode == 0x80131904)
// ...
return null;
throw;
}
how to get error code from exception in c#
try {
// some operation causing an exception
}
catch (SqlException e) {
if (e.ErrorCode == 0x80131904)
// ...
return null;
throw;
}
c# return error status code based on exception
public HttpResponseMessage GetComputingDevice(string id)
{
ComputingDevice computingDevice =
_db.Devices.OfType<ComputingDevice>()
.SingleOrDefault(c => c.AssetId == id);
if (computingDevice == null)
{
return this.Request.CreateResponse(HttpStatusCode.NotFound);
}
if (this.Request.ClientHasStaleData(computingDevice.ModifiedDate))
{
return this.Request.CreateResponse<ComputingDevice>(
HttpStatusCode.OK, computingDevice);
}
else
{
return this.Request.CreateResponse(HttpStatusCode.NotModified);
}
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us