|
2 | 2 |
|
3 | 3 | import com.github.switcherapi.client.SwitcherContextBase; |
4 | 4 | import com.github.switcherapi.client.SwitcherExecutor; |
5 | | -import com.github.switcherapi.client.exception.SwitcherContextException; |
6 | | -import com.github.switcherapi.client.exception.SwitcherException; |
7 | | -import com.github.switcherapi.client.exception.SwitcherSnapshotLoadException; |
8 | | -import com.github.switcherapi.client.exception.SwitchersValidationException; |
| 5 | +import com.github.switcherapi.client.exception.*; |
9 | 6 | import com.github.switcherapi.client.model.ContextKey; |
10 | 7 | import com.github.switcherapi.client.model.Switcher; |
11 | 8 | import com.github.switcherapi.client.model.criteria.Domain; |
@@ -71,12 +68,20 @@ public CriteriaResponse executeCriteria(final Switcher switcher) { |
71 | 68 | SwitcherUtils.debug(logger, "switcher: {}", switcher); |
72 | 69 |
|
73 | 70 | CriteriaResponse response; |
74 | | - if (switcher.isRemote()) { |
75 | | - response = this.clientRemote.executeCriteria(switcher); |
76 | | - SwitcherUtils.debug(logger, "[Remote] response: {}", response); |
77 | | - } else { |
78 | | - response = this.clientLocalService.executeCriteria(switcher, this.domain); |
79 | | - SwitcherUtils.debug(logger, "[Local] response: {}", response); |
| 71 | + try { |
| 72 | + if (switcher.isRemote()) { |
| 73 | + response = this.clientRemote.executeCriteria(switcher); |
| 74 | + SwitcherUtils.debug(logger, "[Remote] response: {}", response); |
| 75 | + } else { |
| 76 | + response = this.clientLocalService.executeCriteria(switcher, this.domain); |
| 77 | + SwitcherUtils.debug(logger, "[Local] response: {}", response); |
| 78 | + } |
| 79 | + } catch (SwitcherKeyNotFoundException e) { |
| 80 | + if (StringUtils.isNotBlank(switcher.getDefaultResult())) { |
| 81 | + return CriteriaResponse.buildFromDefault(switcher); |
| 82 | + } |
| 83 | + |
| 84 | + throw e; |
80 | 85 | } |
81 | 86 |
|
82 | 87 | return response; |
|
0 commit comments