@@ -296,21 +296,36 @@ struct Trial {
296296}
297297
298298/// Possible errors during [`TpeOptimizerBuilder::build`].
299- #[ derive( Debug , Clone , thiserror :: Error ) ]
299+ #[ derive( Debug , Clone ) ]
300300pub enum BuildError {
301- #[ error( "the value of `gamma` must be in the range from 0.0 to 1.0" ) ]
302301 /// The value of `gamma` must be in the range from `0.0` to `1.0`.
303302 GammaOutOfRange ,
304303
305- #[ error( "the value of `candidates` must be a positive integer" ) ]
306304 /// The value of `candidates` must be a positive integer.
307305 ZeroCandidates ,
308306}
309307
308+ impl std:: fmt:: Display for BuildError {
309+ fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
310+ match self {
311+ BuildError :: GammaOutOfRange => {
312+ write ! (
313+ f,
314+ "the value of `gamma` must be in the range from 0.0 to 1.0"
315+ )
316+ }
317+ BuildError :: ZeroCandidates => {
318+ write ! ( f, "the value of `candidates` must be a positive integer" )
319+ }
320+ }
321+ }
322+ }
323+
324+ impl std:: error:: Error for BuildError { }
325+
310326/// Possible errors during [`TpeOptimizer::tell`].
311- #[ derive( Debug , Clone , thiserror :: Error ) ]
327+ #[ derive( Debug , Clone ) ]
312328pub enum TellError {
313- #[ error( "the parameter value {param} is out of the range {range}" ) ]
314329 /// The parameter value is out of the range.
315330 ParamOutOfRange {
316331 /// Actual parameter value.
@@ -319,11 +334,29 @@ pub enum TellError {
319334 range : Range ,
320335 } ,
321336
322- #[ error( "NaN value is not allowed" ) ]
323337 /// NaN value is not allowed.
324338 NanValue ,
325339}
326340
341+ impl std:: fmt:: Display for TellError {
342+ fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
343+ match self {
344+ TellError :: ParamOutOfRange { param, range } => {
345+ write ! (
346+ f,
347+ "the parameter value {} is out of the range {}" ,
348+ param, range
349+ )
350+ }
351+ TellError :: NanValue => {
352+ write ! ( f, "NaN value is not allowed" )
353+ }
354+ }
355+ }
356+ }
357+
358+ impl std:: error:: Error for TellError { }
359+
327360#[ cfg( test) ]
328361mod tests {
329362 use super :: * ;
0 commit comments