File tree 1 file changed +9
-3
lines changed
1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change 2
2
3
3
namespace PartechGSS \Laravel \FeatureToggle ;
4
4
5
+ use Exception ;
5
6
use PartechGSS \Laravel \FeatureToggle \Contracts \FeatureToggleClient ;
6
7
use PartechGSS \Laravel \FeatureToggle \Lib \SplitIOFeatureToggleClient ;
7
8
use Illuminate \Http \Request ;
9
+ use Illuminate \Support \Facades \Log ;
8
10
use Illuminate \Support \ServiceProvider ;
9
11
use SplitIO \Sdk ;
10
12
use SplitIO \Sdk \Factory \SplitFactoryInterface ;
@@ -24,11 +26,15 @@ public function register()
24
26
25
27
$ this ->app ->singleton (FeatureToggleClient::class, function ($ app ) {
26
28
if (config ('feature-toggle ' )) {
27
- if (config ('feature-toggle.provider ' ) === 'splitio ' ) {
29
+ try {
30
+ // This code fails when when the $HOME/split.yaml file
31
+ // is missing, most notable when run from composer.
32
+ // Just log, then ignore it.
28
33
return new SplitIOFeatureToggleClient (static ::getSplitIOFactory ());
34
+ } catch (Exception $ e ) {
35
+ Log::warning ("Unable to initialize Split.IO: ( {$ e ->getMessage ()}). All features will default to control treatments. " );
36
+ return ;
29
37
}
30
-
31
- throw new \Exception ("Unrecognized feature toggle provider " . config ('feature-toggle.provider ' ));
32
38
}
33
39
});
34
40
}
You can’t perform that action at this time.
0 commit comments