exception: catch by reference
`catch` should always be done by reference to avoid object slicing and
excess copy-constructor calls. Preference is for exceptions to also
be caught 'const'. (Both of these come from the C++ Core Guidelines)
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: I7753abbef218a87ceecbd068245c14f413fadabc
diff --git a/src/kvm_websocket_test.cpp b/src/kvm_websocket_test.cpp
index 4016329..c01b7e5 100644
--- a/src/kvm_websocket_test.cpp
+++ b/src/kvm_websocket_test.cpp
@@ -40,7 +40,7 @@
c.close();
break;
}
- catch (std::exception e)
+ catch (const std::exception& e)
{
// do nothing. We expect this to fail while the server is
// starting up
@@ -111,4 +111,4 @@
EXPECT_EQ(open_string, "RFB 003.008");
app.stop();
-}
\ No newline at end of file
+}
diff --git a/src/security_headers_middleware_test.cpp b/src/security_headers_middleware_test.cpp
index f5cd3d5..80df725 100644
--- a/src/security_headers_middleware_test.cpp
+++ b/src/security_headers_middleware_test.cpp
@@ -33,7 +33,7 @@
c.close();
break;
}
- catch (std::exception e)
+ catch (const std::exception& e)
{
// do nothing. We expect this to fail while the server is
// starting up
diff --git a/src/token_authorization_middleware_test.cpp b/src/token_authorization_middleware_test.cpp
index fcb5b65..a93f8c8 100644
--- a/src/token_authorization_middleware_test.cpp
+++ b/src/token_authorization_middleware_test.cpp
@@ -89,7 +89,7 @@
c.connect(asio::ip::tcp::endpoint(
asio::ip::address::from_string("127.0.0.1"), 45451));
}
- catch (std::exception e)
+ catch (const std::exception& e)
{
// do nothing
}
@@ -123,7 +123,7 @@
c.connect(asio::ip::tcp::endpoint(
asio::ip::address::from_string("127.0.0.1"), 45451));
}
- catch (std::exception e)
+ catch (const std::exception& e)
{
// do nothing
}
@@ -169,7 +169,7 @@
c.close();
break;
}
- catch (std::exception e)
+ catch (const std::exception& e)
{
// do nothing. We expect this to fail while the server is
// starting up
@@ -259,7 +259,7 @@
c.close();
break;
}
- catch (std::exception e)
+ catch (const std::exception& e)
{
// do nothing. We expect this to fail while the server is
// starting up