Fix the build for older macOS.
[dcpomatic.git] / src / lib / exceptions.cc
1 /*
2     Copyright (C) 2012-2021 Carl Hetherington <cth@carlh.net>
3
4     This file is part of DCP-o-matic.
5
6     DCP-o-matic is free software; you can redistribute it and/or modify
7     it under the terms of the GNU General Public License as published by
8     the Free Software Foundation; either version 2 of the License, or
9     (at your option) any later version.
10
11     DCP-o-matic is distributed in the hope that it will be useful,
12     but WITHOUT ANY WARRANTY; without even the implied warranty of
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14     GNU General Public License for more details.
15
16     You should have received a copy of the GNU General Public License
17     along with DCP-o-matic.  If not, see <http://www.gnu.org/licenses/>.
18
19 */
20
21
22 #include "exceptions.h"
23 #include "compose.hpp"
24
25 #include "i18n.h"
26
27
28 using std::string;
29 using std::runtime_error;
30 using boost::optional;
31
32
33 /** @param f File that we were trying to open */
34 OpenFileError::OpenFileError (boost::filesystem::path f, int error, Mode mode)
35         : FileError (
36                 String::compose (
37                         mode == READ_WRITE ? _("could not open file %1 for read/write (%2)") :
38                         (mode == READ ? _("could not open file %1 for read (%2)") : _("could not open file %1 for write (%2)")),
39                         f.string(),
40                         error),
41                 f
42                 )
43 {
44
45 }
46
47
48 FileNotFoundError::FileNotFoundError (boost::filesystem::path f)
49         : runtime_error(String::compose("File %1 not found", f.string()))
50         , _file (f)
51 {
52
53 }
54
55
56 ReadFileError::ReadFileError (boost::filesystem::path f, int e)
57         : FileError (String::compose(_("could not read from file %1 (%2)"), f.string(), strerror(e)), f)
58 {
59
60 }
61
62
63 WriteFileError::WriteFileError (boost::filesystem::path f, int e)
64         : FileError (String::compose(_("could not write to file %1 (%2)"), f.string(), strerror(e)), f)
65 {
66
67 }
68
69
70 MissingSettingError::MissingSettingError (string s)
71         : SettingError (s, String::compose(_("Missing required setting %1"), s))
72 {
73
74 }
75
76
77 PixelFormatError::PixelFormatError (string o, AVPixelFormat f)
78         : runtime_error (String::compose(_("Cannot handle pixel format %1 during %2"), (int) f, o))
79 {
80
81 }
82
83
84 TextSubtitleError::TextSubtitleError (string saw, string expecting, boost::filesystem::path f)
85         : FileError (String::compose(_("Error in subtitle file: saw %1 while expecting %2"), saw.empty() ? "[nothing]" : saw, expecting), f)
86 {
87
88 }
89
90
91 InvalidSignerError::InvalidSignerError ()
92         : runtime_error (_("The certificate chain for signing is invalid"))
93 {
94
95 }
96
97
98 InvalidSignerError::InvalidSignerError (string reason)
99         : runtime_error (String::compose(_("The certificate chain for signing is invalid (%1)"), reason))
100 {
101
102 }
103
104
105 ProgrammingError::ProgrammingError (string file, int line, string message)
106         : runtime_error (String::compose(_("Programming error at %1:%2 %3"), file, line, message))
107 {
108
109 }
110
111
112 KDMAsContentError::KDMAsContentError ()
113         : runtime_error (_("This file is a KDM.  KDMs should be added to DCP content by right-clicking the content and choosing \"Add KDM\"."))
114 {
115
116 }
117
118
119 KDMError::KDMError (string s, string d)
120         : runtime_error (String::compose("%1 (%2)", s, d))
121         , _summary (s)
122         , _detail (d)
123 {
124
125 }
126
127
128 GLError::GLError (char const* last, int e)
129         : runtime_error (String::compose("%1 failed %2", last, e))
130 {
131
132 }
133
134
135 GLError::GLError (char const* message)
136         : runtime_error (message)
137 {
138
139 }
140
141
142 CopyError::CopyError (string m, optional<int> n)
143         : runtime_error (String::compose("%1%2", m, n ? String::compose(" (%1)", *n) : ""))
144         , _message (m)
145         , _number (n)
146 {
147
148 }
149
150
151 CommunicationFailedError::CommunicationFailedError ()
152         : CopyError (_("Lost communication between main and writer processes"))
153 {
154
155 }
156
157
158 VerifyError::VerifyError (string m, int n)
159         : runtime_error (String::compose("%1 (%2)", m, n))
160         , _message (m)
161         , _number (n)
162 {
163
164 }
165