From 4c1600bbb5bc631dafda2ed7cf97bea378fc74a4 Mon Sep 17 00:00:00 2001 From: bruceperens Date: Thu, 24 Apr 2014 18:43:31 +0000 Subject: [PATCH] Clean up error messages for open failures. git-svn-id: https://svn.code.sf.net/p/freetel/code@1553 01035d8c-6547-0410-b346-abe4f91aad63 --- freedv-server/source/driver_manager.cpp | 2 +- freedv-server/source/platform/linux/evdev.cpp | 15 ++++++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/freedv-server/source/driver_manager.cpp b/freedv-server/source/driver_manager.cpp index 09221d26..a6686582 100644 --- a/freedv-server/source/driver_manager.cpp +++ b/freedv-server/source/driver_manager.cpp @@ -61,7 +61,7 @@ namespace FreeDV { return (*(list->creator))(parameters); } catch(std::exception & e) { - std::cerr << "Open " << type << " \"" << key << "\": " << e.what() << std::endl; + std::cerr << "Open " << type << " \"" << key << ':' << parameters << "\": " << e.what() << std::endl; return 0; } } diff --git a/freedv-server/source/platform/linux/evdev.cpp b/freedv-server/source/platform/linux/evdev.cpp index dd663570..27100418 100644 --- a/freedv-server/source/platform/linux/evdev.cpp +++ b/freedv-server/source/platform/linux/evdev.cpp @@ -29,15 +29,18 @@ namespace FreeDV { do_throw( const int error, const char * name, - const char * special_file, + const char * special_file = 0, const char * message = 0) { std::ostringstream str; str << "EVDEV "; - str << '\"' << name << "\" device \"" << special_file - << "\" set-up error: "; + str << "\"evdev:" << name << '\"'; + if ( special_file ) + str << " device \"" << special_file << '\"'; + + str << " set-up error: "; if ( message ) { str << message; if ( error ) @@ -244,8 +247,14 @@ namespace FreeDV { if ( fd < 0 ) do_throw(errno, name, special_file, "open"); + + return; } } + throw std::runtime_error( + "No device was found that matched the provided name." \ + " The device may not be attached," \ + " or root privileges may be required to access it"); } EvDev::~EvDev() -- 2.25.1