Discussion:
[PATCH] style: catch exceptions by reference
Sergey Senozhatsky
2012-04-29 09:53:23 UTC
Permalink
Common practive for exceptions is to 'throw by value, catch by reference'.

Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky-***@public.gmane.org>

---

src/devices/ahci.cpp | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/devices/ahci.cpp b/src/devices/ahci.cpp
index 1d2c252..26f83a3 100644
--- a/src/devices/ahci.cpp
+++ b/src/devices/ahci.cpp
@@ -170,7 +170,8 @@ void ahci::start_measurement(void)
file.close();
}
#ifndef DISABLE_TRYCATCH
- catch (std::ios_base::failure c) {
+ catch (std::ios_base::failure &c) {
+ fprintf(stderr, "%s\n", c.what());
}
#endif

@@ -204,7 +205,8 @@ void ahci::end_measurement(void)
file.close();
}
#ifndef DISABLE_TRYCATCH
- catch (std::ios_base::failure c) {
+ catch (std::ios_base::failure &c) {
+ fprintf(stderr, "%s\n", c.what());
}
#endif
if (end_active < start_active)

Loading...