481d2e89dd668fd82b7e78c5651a0df1a2482e84
[dcpomatic.git] / src / lib / exceptions.cc
1 /*
2     Copyright (C) 2012-2014 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 #include "exceptions.h"
22 #include "compose.hpp"
23
24 #include "i18n.h"
25
26 using std::string;
27 using std::runtime_error;
28
29 /** @param f File that we were trying to open */
30 OpenFileError::OpenFileError (boost::filesystem::path f, int error, bool reading)
31         : FileError (
32                 String::compose (
33                         reading ? _("could not open file %1 for reading (%2)") : _("could not open file %1 for writing (%2)"),
34                         f.string(),
35                         error),
36                 f
37                 )
38 {
39
40 }
41
42 ReadFileError::ReadFileError (boost::filesystem::path f, int e)
43         : FileError (String::compose (_("could not read from file %1 (%2)"), f.string(), strerror (e)), f)
44 {
45
46 }
47
48 WriteFileError::WriteFileError (boost::filesystem::path f, int e)
49         : FileError (String::compose (_("could not write to file %1 (%2)"), f.string(), strerror (e)), f)
50 {
51
52 }
53
54 MissingSettingError::MissingSettingError (string s)
55         : SettingError (s, String::compose (_("Missing required setting %1"), s))
56 {
57
58 }
59
60 PixelFormatError::PixelFormatError (string o, AVPixelFormat f)
61         : runtime_error (String::compose (_("Cannot handle pixel format %1 during %2"), (int) f, o))
62 {
63
64 }
65
66 TextSubtitleError::TextSubtitleError (string saw, string expecting, boost::filesystem::path f)
67         : FileError (String::compose (_("Error in subtitle file: saw %1 while expecting %2"), saw.empty() ? "[nothing]" : saw, expecting), f)
68 {
69
70 }
71
72 InvalidSignerError::InvalidSignerError ()
73         : runtime_error (_("The certificate chain for signing is invalid"))
74 {
75
76 }
77
78 InvalidSignerError::InvalidSignerError (string reason)
79         : runtime_error (String::compose (_("The certificate chain for signing is invalid (%1)"), reason))
80 {
81
82 }
83
84 ProgrammingError::ProgrammingError (string file, int line, string message)
85         : runtime_error (String::compose (_("Programming error at %1:%2 %3"), file, line, message))
86 {
87
88 }
89
90 KDMAsContentError::KDMAsContentError ()
91         : runtime_error (_("This file is a KDM.  KDMs should be added to DCP content by right-clicking the content and choosing \"Add KDM\"."))
92 {
93
94 }
95
96 KDMError::KDMError (string s, string d)
97         : runtime_error (String::compose ("%1 (%2)", s, d))
98         , _summary (s)
99         , _detail (d)
100 {
101
102 }