@@ -67,9 +67,8 @@ struct llvm::yaml::MappingTraits<
67
67
namespace clang {
68
68
namespace mrdox {
69
69
70
- Error
71
70
ConfigImpl::
72
- construct (
71
+ ConfigImpl (
73
72
llvm::StringRef workingDir_,
74
73
llvm::StringRef configYaml_,
75
74
llvm::StringRef extraYaml_)
@@ -78,7 +77,7 @@ construct(
78
77
namespace path = llvm::sys::path;
79
78
80
79
if (! files::isAbsolute (workingDir_))
81
- return Error (" path \" {}\" is not absolute" , workingDir_);
80
+ throw Error (" path \" {}\" is not absolute" , workingDir_);
82
81
workingDir = files::makeDirsy (files::normalizePath (workingDir_));
83
82
configYaml = configYaml_;
84
83
extraYaml = extraYaml_;
@@ -89,14 +88,14 @@ construct(
89
88
yin.setAllowUnknownKeys (true );
90
89
yin >> *this ;
91
90
if (auto ec = yin.error ())
92
- return Error (ec);
91
+ throw Error (ec);
93
92
}
94
93
{
95
94
llvm::yaml::Input yin (extraYaml, this , yamlDiagnostic);
96
95
yin.setAllowUnknownKeys (true );
97
96
yin >> *this ;
98
97
if (auto ec = yin.error ())
99
- return Error (ec);
98
+ throw Error (ec);
100
99
}
101
100
102
101
// Post-process as needed
@@ -112,13 +111,7 @@ construct(
112
111
name = files::makePosixStyle (
113
112
files::makeAbsolute (name, workingDir));
114
113
115
- return Error::success ();
116
- }
117
-
118
- ConfigImpl::
119
- ConfigImpl ()
120
- : threadPool_(0 )
121
- {
114
+ threadPool_.reset (concurrency);
122
115
}
123
116
124
117
// ------------------------------------------------
@@ -174,10 +167,16 @@ createConfigFromYAML(
174
167
llvm::StringRef configYaml,
175
168
llvm::StringRef extraYaml)
176
169
{
177
- auto config = std::make_shared<ConfigImpl>();
178
- if (auto err = config->construct (workingDir, configYaml, extraYaml))
170
+ try
171
+ {
172
+ auto config = std::make_shared<ConfigImpl>(
173
+ workingDir, configYaml, extraYaml);
174
+ return config;
175
+ }
176
+ catch (Error err)
177
+ {
179
178
return err;
180
- return config;
179
+ }
181
180
}
182
181
183
182
Expected<std::shared_ptr<ConfigImpl const >>
@@ -202,10 +201,16 @@ loadConfigFile(
202
201
auto workingDir = files::getParentDir (*absPath);
203
202
204
203
// attempt to create the config
205
- auto config = std::make_shared<ConfigImpl>();
206
- if (auto err = config->construct (workingDir, *text, extraYaml))
204
+ try
205
+ {
206
+ auto config = std::make_shared<ConfigImpl>(
207
+ workingDir, *text, extraYaml);
208
+ return config;
209
+ }
210
+ catch (Error err)
211
+ {
207
212
return err;
208
- return config;
213
+ }
209
214
}
210
215
211
216
} // mrdox
0 commit comments