]> Dogcows Code - chaz/yoink/blob - src/ErrorHandler.cc
sockets documentation and cleanup
[chaz/yoink] / src / ErrorHandler.cc
1
2 /*] Copyright (c) 2009-2010, Charles McGarvey [**************************
3 **] All rights reserved.
4 *
5 * vi:ts=4 sw=4 tw=75
6 *
7 * Distributable under the terms and conditions of the 2-clause BSD license;
8 * see the file COPYING for a complete text of the license.
9 *
10 **************************************************************************/
11
12 #include <sstream>
13
14 #include "ErrorHandler.hh"
15
16
17 std::string getErrorString(const Mf::Error& error)
18 {
19 std::string str;
20
21 switch(error.code())
22 {
23 case Mf::Error::ALC_INIT:
24 str += "An error occurred during OpenAL initialization: ";
25 str += error.what();
26 return str;
27
28 case Mf::Error::FASTEVENTS_INIT:
29 case Mf::Error::SDL_INIT:
30 str += "An error occurred during SDL initialization: ";
31 str += error.what();
32 return str;
33
34 case Mf::Error::FILE_NOT_FOUND:
35 str += "A required file (";
36 str += error.what();
37 str += ") could not be found.";
38 return str;
39
40 case Mf::Error::OPENAL_INIT:
41 str += "The audio library returned an error: ";
42 str += error.what();
43 return str;
44
45 case Mf::Error::RESOURCE_NOT_FOUND:
46 str += "A required resource (";
47 str += error.what();
48 str += ") could not be found.";
49 return str;
50
51 case Mf::Error::SCRIPT_ERROR:
52 str += "An error occurred in a script: ";
53 str == error.what();
54 return str;
55
56 case Mf::Error::SDL_VIDEOMODE:
57 str += "An error occurred while trying to set up the graphics.";
58 return str;
59
60 case Mf::Error::UNKNOWN_AUDIO_FORMAT:
61 str += "An error occurred while trying to load an audio file, ";
62 str += error.what();
63 str += ".";
64 return str;
65
66 case Mf::Error::UNKNOWN_IMAGE_FORMAT:
67 str += "An error occurred while trying to load an image file, ";
68 str += error.what();
69 str += ".";
70 return str;
71 }
72
73 std::ostringstream stream;
74 stream << "An unknown error (code " << error.code() << ") occurred.";
75 return stream.str();
76 }
77
This page took 0.031264 seconds and 4 git commands to generate.