00001 /** 00002 \file Robots/LoBot/misc/LoExcept.C 00003 \brief Various exceptions thrown by different Robolocust subsystems. 00004 */ 00005 00006 // //////////////////////////////////////////////////////////////////// // 00007 // The iLab Neuromorphic Vision C++ Toolkit - Copyright (C) 2000-2005 // 00008 // by the University of Southern California (USC) and the iLab at USC. // 00009 // See http://iLab.usc.edu for information about this project. // 00010 // //////////////////////////////////////////////////////////////////// // 00011 // Major portions of the iLab Neuromorphic Vision Toolkit are protected // 00012 // under the U.S. patent ``Computation of Intrinsic Perceptual Saliency // 00013 // in Visual Environments, and Applications'' by Christof Koch and // 00014 // Laurent Itti, California Institute of Technology, 2001 (patent // 00015 // pending; application number 09/912,225 filed July 23, 2001; see // 00016 // http://pair.uspto.gov/cgi-bin/final/home.pl for current status). // 00017 // //////////////////////////////////////////////////////////////////// // 00018 // This file is part of the iLab Neuromorphic Vision C++ Toolkit. // 00019 // // 00020 // The iLab Neuromorphic Vision C++ Toolkit is free software; you can // 00021 // redistribute it and/or modify it under the terms of the GNU General // 00022 // Public License as published by the Free Software Foundation; either // 00023 // version 2 of the License, or (at your option) any later version. // 00024 // // 00025 // The iLab Neuromorphic Vision C++ Toolkit is distributed in the hope // 00026 // that it will be useful, but WITHOUT ANY WARRANTY; without even the // 00027 // implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // 00028 // PURPOSE. See the GNU General Public License for more details. // 00029 // // 00030 // You should have received a copy of the GNU General Public License // 00031 // along with the iLab Neuromorphic Vision C++ Toolkit; if not, write // 00032 // to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, // 00033 // Boston, MA 02111-1307 USA. // 00034 // //////////////////////////////////////////////////////////////////// // 00035 // 00036 // Primary maintainer for this file: mviswana usc edu 00037 // $HeadURL: svn://isvn.usc.edu/software/invt/trunk/saliency/src/Robots/LoBot/misc/LoExcept.C $ 00038 // $Id: LoExcept.C 13967 2010-09-18 08:00:07Z mviswana $ 00039 // 00040 00041 //------------------------------ HEADERS -------------------------------- 00042 00043 // lobot headers 00044 #include "Robots/LoBot/misc/LoExcept.H" 00045 00046 // Standard C++ headers 00047 #include <map> 00048 00049 //----------------------------- NAMESPACE ------------------------------- 00050 00051 namespace lobot { 00052 00053 //-------------------------- ERROR MESSAGES ----------------------------- 00054 00055 /* 00056 ************************************************************************ 00057 * * 00058 * DEVNOTE: Steps for adding a new error * 00059 * ------------------------------------- * 00060 * 1. Add an enum for the new error code in LoExcept.H. * 00061 * * 00062 * 2. Add a #defined string for the new error in this section of * 00063 * this file. * 00064 * * 00065 * 3. Add an initializer for the new error in the constructor of the * 00066 * private messages class defined in the next section of this * 00067 * file. * 00068 * * 00069 * 4. If required, define a new exception struct derived from * 00070 * lobot::uhoh in LoExcept.H and define its constructor in the * 00071 * EXCEPTION CLASSES section of this file. * 00072 * * 00073 ************************************************************************ 00074 */ 00075 00076 // Library/dependency issues 00077 #ifndef LOEM_MISSING_PTHREAD 00078 #define LOEM_MISSING_PTHREAD \ 00079 "sorry, need the POSIX threads library for multithreading" 00080 #endif 00081 #ifndef LOEM_MISSING_LIBDC1394 00082 #define LOEM_MISSING_LIBDC1394 "sorry, need libdc1394 for capturing " \ 00083 "from FireWire cameras" 00084 #endif 00085 #ifndef LOEM_MISSING_FFMPEG 00086 #define LOEM_MISSING_FFMPEG "sorry, need FFmpeg libraries for " \ 00087 "encoding/decoding movie files" 00088 #endif 00089 #ifndef LOEM_MISSING_OPENCV 00090 #define LOEM_MISSING_OPENCV "sorry, need OpenCV for Horn-Schunck " \ 00091 "optical flow algorithm" 00092 #endif 00093 #ifndef LOEM_MISSING_OPENGL 00094 #define LOEM_MISSING_OPENGL "sorry, need OpenGL and GLUT for " \ 00095 "laser range finder visualization" 00096 #endif 00097 #ifndef LOEM_MISSING_GLEW 00098 #define LOEM_MISSING_GLEW "sorry, off-screen rendering requires " \ 00099 "OpenGL extension wrangler library GLEW" 00100 #endif 00101 #ifndef LOEM_MISSING_LIBURG 00102 #define LOEM_MISSING_LIBURG "sorry, need the URG library for " \ 00103 "interfacing with laser range finder" 00104 #endif 00105 #ifndef LOEM_MISSING_LIBDEVIL 00106 #define LOEM_MISSING_LIBDEVIL "sorry, need OpenIL/DevIL library for " \ 00107 "saving screen capture frames to disk" 00108 #endif 00109 #ifndef LOEM_MISSING_LIBGSL 00110 #define LOEM_MISSING_LIBGSL "sorry, need the GSL library for ICP, etc." 00111 #endif 00112 00113 // Thread related errors 00114 #ifndef LOEM_THREAD_CREATION_FAILURE 00115 #define LOEM_THREAD_CREATION_FAILURE "unable to create new thread" 00116 #endif 00117 #ifndef LOEM_MUTEX_INIT_ERROR 00118 #define LOEM_MUTEX_INIT_ERROR "unable to initialize mutex" 00119 #endif 00120 #ifndef LOEM_COND_INIT_ERROR 00121 #define LOEM_COND_INIT_ERROR "unable to initialize condition variable" 00122 #endif 00123 #ifndef LOEM_RWLOCK_INIT_ERROR 00124 #define LOEM_RWLOCK_INIT_ERROR "unable to initialize reader-writer lock" 00125 #endif 00126 #ifndef LOEM_RWLOCK_RDLOCK_FAILED 00127 #define LOEM_RWLOCK_RDLOCK_FAILED "unable to read-lock reader-writer lock" 00128 #endif 00129 #ifndef LOEM_RWLOCK_WRLOCK_FAILED 00130 #define LOEM_RWLOCK_WRLOCK_FAILED "unable to write-lock reader-writer lock" 00131 #endif 00132 00133 // Bus errors 00134 #ifndef LOEM_INIT_PROBLEM 00135 #define LOEM_INIT_PROBLEM "unable to acquire raw 1394 handle" 00136 #endif 00137 #ifndef LOEM_NO_CAMERAS 00138 #define LOEM_NO_CAMERAS "no cameras connected to FireWire bus" 00139 #endif 00140 #ifndef LOEM_HIGHEST_NODE 00141 #define LOEM_HIGHEST_NODE "cannot work with camera that is "\ 00142 "highest numbered node on FireWire bus" 00143 #endif 00144 00145 // Camera node errors 00146 #ifndef LOEM_CAMERA_NODES_FREED 00147 #define LOEM_CAMERA_NODES_FREED "sorry, camera nodes have been freed" 00148 #endif 00149 #ifndef LOEM_BAD_CAMERA_NODE_INDEX 00150 #define LOEM_BAD_CAMERA_NODE_INDEX "camera node index out of range" 00151 #endif 00152 00153 // Camera initialization errors 00154 #ifndef LOEM_SETUP_FAILED 00155 #define LOEM_SETUP_FAILED "unable to setup camera for capture" 00156 #endif 00157 #ifndef LOEM_START_TRANSMISSION_FAILED 00158 #define LOEM_START_TRANSMISSION_FAILED "unable to start ISO transmission" 00159 #endif 00160 00161 // Video I/O errors 00162 #ifndef LOEM_MPEG_FILES_NOT_FOUND 00163 #define LOEM_MPEG_FILES_NOT_FOUND \ 00164 "MPEG files specified for playback could not be found" 00165 #endif 00166 #ifndef LOEM_NO_VIDEOSTREAM_SOURCE 00167 #define LOEM_NO_VIDEOSTREAM_SOURCE "video stream source missing" 00168 #endif 00169 #ifndef LOEM_NO_COMPOSITOR_SOURCES 00170 #define LOEM_NO_COMPOSITOR_SOURCES "no compositor sources specified" 00171 #endif 00172 00173 // Laser range finder errors 00174 #ifndef LOEM_LRF_CONNECTION_FAILURE 00175 #define LOEM_LRF_CONNECTION_FAILURE \ 00176 "unable to connect to laser range finder device" 00177 #endif 00178 #ifndef LOEM_LRF_DATA_RETRIEVAL_FAILURE 00179 #define LOEM_LRF_DATA_RETRIEVAL_FAILURE \ 00180 "unable to retrieve data from laser range finder" 00181 #endif 00182 #ifndef LOEM_NO_LRF_SOURCE 00183 #define LOEM_NO_LRF_SOURCE "laser range finder is not the input source" 00184 #endif 00185 00186 // I/O errors 00187 #ifndef LOEM_SERIAL_PORT_INIT_ERROR 00188 #define LOEM_SERIAL_PORT_INIT_ERROR "unable to initialize serial port" 00189 #endif 00190 #ifndef LOEM_SERIAL_PORT_BAD_ARG 00191 #define LOEM_SERIAL_PORT_BAD_ARG \ 00192 "bad argument to serial port read/write call" 00193 #endif 00194 #ifndef LOEM_SERIAL_PORT_READ_ERROR 00195 #define LOEM_SERIAL_PORT_READ_ERROR "unable to read from serial port" 00196 #endif 00197 #ifndef LOEM_SERIAL_PORT_WRITE_ERROR 00198 #define LOEM_SERIAL_PORT_WRITE_ERROR "unable to write to serial port" 00199 #endif 00200 00201 // Motor errors 00202 #ifndef LOEM_MOTOR_READ_FAILURE 00203 #define LOEM_MOTOR_READ_FAILURE "unable to read from motor serial port" 00204 #endif 00205 #ifndef LOEM_IN_PLACE_TURNS_NOT_SUPPORTED 00206 #define LOEM_IN_PLACE_TURNS_NOT_SUPPORTED \ 00207 "sorry, selected robot platform does not support in-place turns" 00208 #endif 00209 00210 // Incorrect command line options and configuration settings 00211 #ifndef LOEM_BAD_OPTION 00212 #define LOEM_BAD_OPTION "command line parse error" 00213 #endif 00214 #ifndef LOEM_NO_SUCH_CONFIG_FILE 00215 #define LOEM_NO_SUCH_CONFIG_FILE "unable to open specified config file" 00216 #endif 00217 #ifndef LOEM_CONFIG_FILE_SYNTAX_ERROR 00218 #define LOEM_CONFIG_FILE_SYNTAX_ERROR "syntax error in config file" 00219 #endif 00220 #ifndef LOEM_CONFIG_FILE_MEMORY_ERROR 00221 #define LOEM_CONFIG_FILE_MEMORY_ERROR \ 00222 "ran out of memory while parsing config file" 00223 #endif 00224 #ifndef LOEM_BAD_GEOMETRY_SPEC 00225 #define LOEM_BAD_GEOMETRY_SPEC "bad drawable geometry specification" 00226 #endif 00227 #ifndef LOEM_MISSING_CMDLINE_ARGS 00228 #define LOEM_MISSING_CMDLINE_ARGS "required command line arguments missing" 00229 #endif 00230 #ifndef LOEM_BAD_RESULTS_SPECS 00231 #define LOEM_BAD_RESULTS_SPECS "bad results file and dir specs" 00232 #endif 00233 00234 // Unknown model/algorithms 00235 #ifndef LOEM_UNKNOWN_LOCUST_MODEL 00236 #define LOEM_UNKNOWN_LOCUST_MODEL "unknown locust model" 00237 #endif 00238 #ifndef LOEM_UNKNOWN_BEHAVIOR 00239 #define LOEM_UNKNOWN_BEHAVIOR "unknown behavior" 00240 #endif 00241 #ifndef LOEM_UNKNOWN_ROBOT_PLATFORM 00242 #define LOEM_UNKNOWN_ROBOT_PLATFORM "unknown robot platform" 00243 #endif 00244 00245 // Arbiter errors 00246 #ifndef LOEM_ARBITER_NOT_RUNNING 00247 #define LOEM_ARBITER_NOT_RUNNING "DAMN arbiter is no longer running" 00248 #endif 00249 #ifndef LOEM_UNSUPPORTED_TURN_DIRECTION 00250 #define LOEM_UNSUPPORTED_TURN_DIRECTION \ 00251 "turn arbiter does not support supplied direction" 00252 #endif 00253 00254 // Behaviour errors 00255 #ifndef LOEM_MOTOR_SYSTEM_MISSING 00256 #define LOEM_MOTOR_SYSTEM_MISSING \ 00257 "motor subsystem required by LGMD module or an active behaviour" 00258 #endif 00259 #ifndef LOEM_LASER_RANGE_FINDER_MISSING 00260 #define LOEM_LASER_RANGE_FINDER_MISSING \ 00261 "behaviour/visualizer needs laser range finder" 00262 #endif 00263 #ifndef LOEM_MAPPING_DISABLED 00264 #define LOEM_MAPPING_DISABLED \ 00265 "selected functionality requires mapping to be enabled" 00266 #endif 00267 #ifndef LOEM_BOGUS_LOW_LEVEL_ODOMETRY 00268 #define LOEM_BOGUS_LOW_LEVEL_ODOMETRY \ 00269 "bogus low-level odometry ==> low-level berserk or bad config" 00270 #endif 00271 #ifndef LOEM_NO_GOALS 00272 #define LOEM_NO_GOALS "behaviour requires at least one goal" 00273 #endif 00274 00275 // Assorted errors 00276 #ifndef LOEM_DANGER_ZONE_LRF_NOT_SETUP 00277 #define LOEM_DANGER_ZONE_LRF_NOT_SETUP \ 00278 "danger zone object requires LRF prior to instantiation" 00279 #endif 00280 #ifndef LOEM_NO_INPUT_SOURCE 00281 #define LOEM_NO_INPUT_SOURCE "no input source for locust LGMD model" 00282 #endif 00283 #ifndef LOEM_NOT_ENOUGH_LOCUSTS 00284 #define LOEM_NOT_ENOUGH_LOCUSTS \ 00285 "need at least 1 locust for visualization and 2 for an EMD" 00286 #endif 00287 #ifndef LOEM_IDC_CONVERGENCE_FAILURE 00288 #define LOEM_IDC_CONVERGENCE_FAILURE \ 00289 "IDC scan matching algorithm failed to converge" 00290 #endif 00291 #ifndef LOEM_PARTICLE_INDEX_OUT_OF_BOUNDS 00292 #define LOEM_PARTICLE_INDEX_OUT_OF_BOUNDS \ 00293 "invalid index for accessing particle state variable" 00294 #endif 00295 #ifndef LOEM_OPENGL_FBO_INIT_ERROR 00296 #define LOEM_OPENGL_FBO_INIT_ERROR \ 00297 "unable to create OpenGL off-screen rendering buffer" 00298 #endif 00299 #ifndef LOEM_GLEW_INIT_ERROR 00300 #define LOEM_GLEW_INIT_ERROR \ 00301 "unable to initialize OpenGL extension wrangler library GLEW" 00302 #endif 00303 #ifndef LOEM_OPENCV_IMAGE_INIT_ERROR 00304 #define LOEM_OPENCV_IMAGE_INIT_ERROR \ 00305 "there was a problem creating some OpenCV image" 00306 #endif 00307 #ifndef LOEM_SIGNALS_MASK_SETUP_FAILURE 00308 #define LOEM_SIGNALS_MASK_SETUP_FAILURE \ 00309 "unable to setup signals mask for shutdown thread" 00310 #endif 00311 #ifndef LOEM_SIGWAIT_FAILED 00312 #define LOEM_SIGWAIT_FAILED \ 00313 "sigwait() system function failed in shutdown thread" 00314 #endif 00315 #ifndef LOEM_LOGIC_ERROR 00316 #define LOEM_LOGIC_ERROR \ 00317 "buggy code! some kind of impossible case or other logic error" 00318 #endif 00319 #ifndef LOEM_BROKEN_FEATURE 00320 #define LOEM_BROKEN_FEATURE "attempt to use a broken feature" 00321 #endif 00322 00323 //------------- MAPPING BETWEEN ERROR CODES AND MESSAGES ---------------- 00324 00325 // Forward declarations 00326 static const char* error_msg(int code) ; 00327 00328 // Quick helper to map error codes to appropriate message strings 00329 class messages { 00330 typedef std::map<int, const char*> msg_map ; 00331 msg_map m_map ; 00332 messages() ; 00333 friend const char* error_msg(int code) ; 00334 } ; 00335 00336 /* 00337 ************************************************************************* 00338 * * 00339 * DEVNOTE: Steps for adding a new error * 00340 * ------------------------------------- * 00341 * 1. Add an enum for the new error code in LoExcept.H. * 00342 * * 00343 * 2. Add a #defined string for the new error to the previous section * 00344 * of this file. * 00345 * * 00346 * 3. Add an initializer for the new error in the following * 00347 * constructor. * 00348 * * 00349 * 4. If required, define a new exception struct derived from * 00350 * lobot::uhoh in LoExcept.H and define its constructor in the * 00351 * next section of this file. * 00352 * * 00353 ************************************************************************* 00354 */ 00355 messages::messages() 00356 { 00357 m_map[MISSING_PTHREAD] = LOEM_MISSING_PTHREAD ; 00358 m_map[MISSING_LIBDC1394] = LOEM_MISSING_LIBDC1394 ; 00359 m_map[MISSING_FFMPEG] = LOEM_MISSING_FFMPEG ; 00360 m_map[MISSING_OPENCV] = LOEM_MISSING_OPENCV ; 00361 m_map[MISSING_OPENGL] = LOEM_MISSING_OPENGL ; 00362 m_map[MISSING_GLEW] = LOEM_MISSING_GLEW ; 00363 m_map[MISSING_LIBURG] = LOEM_MISSING_LIBURG ; 00364 m_map[MISSING_LIBDEVIL] = LOEM_MISSING_LIBDEVIL ; 00365 m_map[MISSING_LIBGSL] = LOEM_MISSING_LIBGSL ; 00366 00367 m_map[THREAD_CREATION_FAILURE] = LOEM_THREAD_CREATION_FAILURE ; 00368 m_map[MUTEX_INIT_ERROR] = LOEM_MUTEX_INIT_ERROR ; 00369 m_map[COND_INIT_ERROR] = LOEM_COND_INIT_ERROR ; 00370 m_map[RWLOCK_INIT_ERROR] = LOEM_RWLOCK_INIT_ERROR ; 00371 m_map[RWLOCK_RDLOCK_FAILED] = LOEM_RWLOCK_RDLOCK_FAILED ; 00372 m_map[RWLOCK_WRLOCK_FAILED] = LOEM_RWLOCK_WRLOCK_FAILED ; 00373 00374 m_map[INIT_PROBLEM] = LOEM_INIT_PROBLEM ; 00375 m_map[NO_CAMERAS] = LOEM_NO_CAMERAS ; 00376 m_map[HIGHEST_NODE] = LOEM_HIGHEST_NODE ; 00377 00378 m_map[SETUP_FAILED] = LOEM_SETUP_FAILED ; 00379 m_map[START_TRANSMISSION_FAILED] = LOEM_START_TRANSMISSION_FAILED ; 00380 00381 m_map[MPEG_FILES_NOT_FOUND] = LOEM_MPEG_FILES_NOT_FOUND ; 00382 m_map[NO_VIDEOSTREAM_SOURCE] = LOEM_NO_VIDEOSTREAM_SOURCE ; 00383 m_map[NO_COMPOSITOR_SOURCES] = LOEM_NO_COMPOSITOR_SOURCES ; 00384 00385 m_map[LRF_CONNECTION_FAILURE] = LOEM_LRF_CONNECTION_FAILURE ; 00386 m_map[LRF_DATA_RETRIEVAL_FAILURE] = LOEM_LRF_DATA_RETRIEVAL_FAILURE ; 00387 m_map[NO_LRF_SOURCE] = LOEM_NO_LRF_SOURCE ; 00388 00389 m_map[SERIAL_PORT_INIT_ERROR] = LOEM_SERIAL_PORT_INIT_ERROR ; 00390 m_map[SERIAL_PORT_BAD_ARG] = LOEM_SERIAL_PORT_BAD_ARG ; 00391 m_map[SERIAL_PORT_READ_ERROR] = LOEM_SERIAL_PORT_READ_ERROR ; 00392 m_map[SERIAL_PORT_WRITE_ERROR] = LOEM_SERIAL_PORT_WRITE_ERROR ; 00393 00394 m_map[MOTOR_READ_FAILURE] = LOEM_MOTOR_READ_FAILURE ; 00395 m_map[IN_PLACE_TURNS_NOT_SUPPORTED] = LOEM_IN_PLACE_TURNS_NOT_SUPPORTED ; 00396 00397 m_map[BAD_OPTION] = LOEM_BAD_OPTION ; 00398 m_map[NO_SUCH_CONFIG_FILE] = LOEM_NO_SUCH_CONFIG_FILE ; 00399 m_map[CONFIG_FILE_SYNTAX_ERROR] = LOEM_CONFIG_FILE_SYNTAX_ERROR ; 00400 m_map[CONFIG_FILE_MEMORY_ERROR] = LOEM_CONFIG_FILE_MEMORY_ERROR ; 00401 m_map[BAD_GEOMETRY_SPEC] = LOEM_BAD_GEOMETRY_SPEC ; 00402 m_map[MISSING_CMDLINE_ARGS] = LOEM_MISSING_CMDLINE_ARGS ; 00403 m_map[BAD_RESULTS_SPECS] = LOEM_BAD_RESULTS_SPECS ; 00404 00405 m_map[UNKNOWN_LOCUST_MODEL] = LOEM_UNKNOWN_LOCUST_MODEL ; 00406 m_map[UNKNOWN_BEHAVIOR] = LOEM_UNKNOWN_BEHAVIOR ; 00407 m_map[UNKNOWN_ROBOT_PLATFORM] = LOEM_UNKNOWN_ROBOT_PLATFORM ; 00408 00409 m_map[ARBITER_NOT_RUNNING] = LOEM_ARBITER_NOT_RUNNING ; 00410 m_map[UNSUPPORTED_TURN_DIRECTION] = LOEM_UNSUPPORTED_TURN_DIRECTION ; 00411 00412 m_map[MOTOR_SYSTEM_MISSING] = LOEM_MOTOR_SYSTEM_MISSING ; 00413 m_map[LASER_RANGE_FINDER_MISSING] = LOEM_LASER_RANGE_FINDER_MISSING ; 00414 m_map[MAPPING_DISABLED] = LOEM_MAPPING_DISABLED ; 00415 m_map[BOGUS_LOW_LEVEL_ODOMETRY] = LOEM_BOGUS_LOW_LEVEL_ODOMETRY ; 00416 m_map[NO_GOALS] = LOEM_NO_GOALS ; 00417 00418 m_map[DANGER_ZONE_LRF_NOT_SETUP] = LOEM_DANGER_ZONE_LRF_NOT_SETUP ; 00419 m_map[NO_INPUT_SOURCE] = LOEM_NO_INPUT_SOURCE ; 00420 m_map[NOT_ENOUGH_LOCUSTS] = LOEM_NOT_ENOUGH_LOCUSTS ; 00421 m_map[PARTICLE_INDEX_OUT_OF_BOUNDS] = LOEM_PARTICLE_INDEX_OUT_OF_BOUNDS ; 00422 m_map[OPENGL_FBO_INIT_ERROR] = LOEM_OPENGL_FBO_INIT_ERROR ; 00423 m_map[GLEW_INIT_ERROR] = LOEM_GLEW_INIT_ERROR ; 00424 m_map[OPENCV_IMAGE_INIT_ERROR] = LOEM_OPENCV_IMAGE_INIT_ERROR ; 00425 m_map[SIGNALS_MASK_SETUP_FAILURE] = LOEM_SIGNALS_MASK_SETUP_FAILURE ; 00426 m_map[SIGWAIT_FAILED] = LOEM_SIGWAIT_FAILED ; 00427 m_map[LOGIC_ERROR] = LOEM_LOGIC_ERROR ; 00428 m_map[BROKEN_FEATURE] = LOEM_BROKEN_FEATURE ; 00429 } 00430 00431 // The following function returns the error message corresponding to the 00432 // specified error code. In order to work correctly, this function will 00433 // need an instance of the above map. The simplest thing to do is to 00434 // instantiate it as a local static variable. 00435 // 00436 // DEVNOTE: Using a global static instance might not work if there are 00437 // other such static global/member variables in other translation units 00438 // (no thanks to the static initialization dependency problem). 00439 static const char* error_msg(int code) 00440 { 00441 static const char* unknown = "unknown error" ; 00442 static const messages M ; 00443 00444 messages::msg_map::const_iterator it = M.m_map.find(code) ; 00445 if (it == M.m_map.end()) 00446 return unknown ; 00447 return it->second ; 00448 } 00449 00450 //------------------------- EXCEPTION CLASSES --------------------------- 00451 00452 // Base for all lobot exceptions 00453 uhoh::uhoh(int code, const std::string& msg) 00454 : runtime_error(msg), m_code(code) 00455 {} 00456 00457 // Missing libraries 00458 missing_libs::missing_libs(int code) 00459 : uhoh(code, error_msg(code)) 00460 {} 00461 00462 // Thread related errors 00463 thread_error::thread_error(int code) 00464 : uhoh(code, error_msg(code)) 00465 {} 00466 00467 // 1394 bus errors 00468 bus_error::bus_error(int code) 00469 : uhoh(code, error_msg(code)) 00470 {} 00471 00472 // Camera errors 00473 camera_error::camera_error(int code) 00474 : uhoh(code, error_msg(code)) 00475 {} 00476 00477 // Video I/O errors 00478 vstream_error::vstream_error(int code) 00479 : uhoh(code, error_msg(code)) 00480 {} 00481 00482 // Laser range finder errors 00483 lrf_error::lrf_error(int code) 00484 : uhoh(code, error_msg(code)) 00485 {} 00486 00487 // I/O errors 00488 io_error::io_error(int code) 00489 : uhoh(code, error_msg(code)) 00490 {} 00491 00492 // Motor errors 00493 motor_error::motor_error(int code) 00494 : uhoh(code, error_msg(code)) 00495 {} 00496 00497 // Incorrect command line options and configuration settings 00498 customization_error::customization_error(int code) 00499 : uhoh(code, error_msg(code)) 00500 {} 00501 00502 // Unknown locust models, integration algorithms, etc. 00503 unknown_model::unknown_model(int code) 00504 : uhoh(code, error_msg(code)) 00505 {} 00506 00507 // Arbiter errors 00508 arbiter_error::arbiter_error(int code) 00509 : uhoh(code, error_msg(code)) 00510 {} 00511 00512 // Behavior errors 00513 behavior_error::behavior_error(int code) 00514 : uhoh(code, error_msg(code)) 00515 {} 00516 00517 // Miscellaneous errors 00518 misc_error::misc_error(int code) 00519 : uhoh(code, error_msg(code)) 00520 {} 00521 00522 //----------------------------------------------------------------------- 00523 00524 } // end of namespace encapsulating this file's definitions 00525 00526 /* So things look consistent in everyone's emacs... */ 00527 /* Local Variables: */ 00528 /* indent-tabs-mode: nil */ 00529 /* End: */