@@ -241,14 +241,14 @@ func (c *InboundDetourConfig) Build() (*core.InboundHandlerConfig, error) {
241
241
}
242
242
rawConfig , err := inboundConfigLoader .LoadWithID (settings , c .Protocol )
243
243
if err != nil {
244
- return nil , errors .New ("failed to load inbound detour config." ).Base (err )
244
+ return nil , errors .New ("failed to load inbound detour config for protocol " , c . Protocol ).Base (err )
245
245
}
246
246
if dokodemoConfig , ok := rawConfig .(* DokodemoConfig ); ok {
247
247
receiverSettings .ReceiveOriginalDestination = dokodemoConfig .Redirect
248
248
}
249
249
ts , err := rawConfig .(Buildable ).Build ()
250
250
if err != nil {
251
- return nil , err
251
+ return nil , errors . New ( "failed to build inbound handler for protocol " , c . Protocol ). Base ( err )
252
252
}
253
253
254
254
return & core.InboundHandlerConfig {
@@ -303,15 +303,15 @@ func (c *OutboundDetourConfig) Build() (*core.OutboundHandlerConfig, error) {
303
303
if c .StreamSetting != nil {
304
304
ss , err := c .StreamSetting .Build ()
305
305
if err != nil {
306
- return nil , err
306
+ return nil , errors . New ( "failed to build stream settings for outbound detour" ). Base ( err )
307
307
}
308
308
senderSettings .StreamSettings = ss
309
309
}
310
310
311
311
if c .ProxySettings != nil {
312
312
ps , err := c .ProxySettings .Build ()
313
313
if err != nil {
314
- return nil , errors .New ("invalid outbound detour proxy settings. " ).Base (err )
314
+ return nil , errors .New ("invalid outbound detour proxy settings" ).Base (err )
315
315
}
316
316
if ps .TransportLayerProxy {
317
317
if senderSettings .StreamSettings != nil {
@@ -331,7 +331,7 @@ func (c *OutboundDetourConfig) Build() (*core.OutboundHandlerConfig, error) {
331
331
if c .MuxSettings != nil {
332
332
ms , err := c .MuxSettings .Build ()
333
333
if err != nil {
334
- return nil , errors .New ("failed to build Mux config. " ).Base (err )
334
+ return nil , errors .New ("failed to build Mux config" ).Base (err )
335
335
}
336
336
senderSettings .MultiplexSettings = ms
337
337
}
@@ -342,11 +342,11 @@ func (c *OutboundDetourConfig) Build() (*core.OutboundHandlerConfig, error) {
342
342
}
343
343
rawConfig , err := outboundConfigLoader .LoadWithID (settings , c .Protocol )
344
344
if err != nil {
345
- return nil , errors .New ("failed to parse to outbound detour config." ).Base (err )
345
+ return nil , errors .New ("failed to load outbound detour config for protocol " , c . Protocol ).Base (err )
346
346
}
347
347
ts , err := rawConfig .(Buildable ).Build ()
348
348
if err != nil {
349
- return nil , err
349
+ return nil , errors . New ( "failed to build outbound handler for protocol " , c . Protocol ). Base ( err )
350
350
}
351
351
352
352
return & core.OutboundHandlerConfig {
@@ -490,7 +490,7 @@ func (c *Config) Override(o *Config, fn string) {
490
490
// Build implements Buildable.
491
491
func (c * Config ) Build () (* core.Config , error ) {
492
492
if err := PostProcessConfigureFile (c ); err != nil {
493
- return nil , err
493
+ return nil , errors . New ( "failed to post-process configuration file" ). Base ( err )
494
494
}
495
495
496
496
config := & core.Config {
@@ -504,21 +504,21 @@ func (c *Config) Build() (*core.Config, error) {
504
504
if c .API != nil {
505
505
apiConf , err := c .API .Build ()
506
506
if err != nil {
507
- return nil , err
507
+ return nil , errors . New ( "failed to build API configuration" ). Base ( err )
508
508
}
509
509
config .App = append (config .App , serial .ToTypedMessage (apiConf ))
510
510
}
511
511
if c .Metrics != nil {
512
512
metricsConf , err := c .Metrics .Build ()
513
513
if err != nil {
514
- return nil , err
514
+ return nil , errors . New ( "failed to build metrics configuration" ). Base ( err )
515
515
}
516
516
config .App = append (config .App , serial .ToTypedMessage (metricsConf ))
517
517
}
518
518
if c .Stats != nil {
519
519
statsConf , err := c .Stats .Build ()
520
520
if err != nil {
521
- return nil , err
521
+ return nil , errors . New ( "failed to build stats configuration" ). Base ( err )
522
522
}
523
523
config .App = append (config .App , serial .ToTypedMessage (statsConf ))
524
524
}
@@ -536,55 +536,55 @@ func (c *Config) Build() (*core.Config, error) {
536
536
if c .RouterConfig != nil {
537
537
routerConfig , err := c .RouterConfig .Build ()
538
538
if err != nil {
539
- return nil , err
539
+ return nil , errors . New ( "failed to build routing configuration" ). Base ( err )
540
540
}
541
541
config .App = append (config .App , serial .ToTypedMessage (routerConfig ))
542
542
}
543
543
544
544
if c .DNSConfig != nil {
545
545
dnsApp , err := c .DNSConfig .Build ()
546
546
if err != nil {
547
- return nil , errors .New ("failed to parse DNS config " ).Base (err )
547
+ return nil , errors .New ("failed to build DNS configuration " ).Base (err )
548
548
}
549
549
config .App = append (config .App , serial .ToTypedMessage (dnsApp ))
550
550
}
551
551
552
552
if c .Policy != nil {
553
553
pc , err := c .Policy .Build ()
554
554
if err != nil {
555
- return nil , err
555
+ return nil , errors . New ( "failed to build policy configuration" ). Base ( err )
556
556
}
557
557
config .App = append (config .App , serial .ToTypedMessage (pc ))
558
558
}
559
559
560
560
if c .Reverse != nil {
561
561
r , err := c .Reverse .Build ()
562
562
if err != nil {
563
- return nil , err
563
+ return nil , errors . New ( "failed to build reverse configuration" ). Base ( err )
564
564
}
565
565
config .App = append (config .App , serial .ToTypedMessage (r ))
566
566
}
567
567
568
568
if c .FakeDNS != nil {
569
569
r , err := c .FakeDNS .Build ()
570
570
if err != nil {
571
- return nil , err
571
+ return nil , errors . New ( "failed to build fake DNS configuration" ). Base ( err )
572
572
}
573
573
config .App = append ([]* serial.TypedMessage {serial .ToTypedMessage (r )}, config .App ... )
574
574
}
575
575
576
576
if c .Observatory != nil {
577
577
r , err := c .Observatory .Build ()
578
578
if err != nil {
579
- return nil , err
579
+ return nil , errors . New ( "failed to build observatory configuration" ). Base ( err )
580
580
}
581
581
config .App = append (config .App , serial .ToTypedMessage (r ))
582
582
}
583
583
584
584
if c .BurstObservatory != nil {
585
585
r , err := c .BurstObservatory .Build ()
586
586
if err != nil {
587
- return nil , err
587
+ return nil , errors . New ( "failed to build burst observatory configuration" ). Base ( err )
588
588
}
589
589
config .App = append (config .App , serial .ToTypedMessage (r ))
590
590
}
@@ -602,7 +602,7 @@ func (c *Config) Build() (*core.Config, error) {
602
602
for _ , rawInboundConfig := range inbounds {
603
603
ic , err := rawInboundConfig .Build ()
604
604
if err != nil {
605
- return nil , err
605
+ return nil , errors . New ( "failed to build inbound config with tag " , rawInboundConfig . Tag ). Base ( err )
606
606
}
607
607
config .Inbound = append (config .Inbound , ic )
608
608
}
@@ -616,7 +616,7 @@ func (c *Config) Build() (*core.Config, error) {
616
616
for _ , rawOutboundConfig := range outbounds {
617
617
oc , err := rawOutboundConfig .Build ()
618
618
if err != nil {
619
- return nil , err
619
+ return nil , errors . New ( "failed to build outbound config with tag " , rawOutboundConfig . Tag ). Base ( err )
620
620
}
621
621
config .Outbound = append (config .Outbound , oc )
622
622
}
0 commit comments