File tree Expand file tree Collapse file tree 2 files changed +43
-0
lines changed Expand file tree Collapse file tree 2 files changed +43
-0
lines changed Original file line number Diff line number Diff line change
1
+ /*
2
+ * Copyright 2019 American Express Travel Related Services Company, Inc.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5
+ * in compliance with the License. You may obtain a copy of the License at
6
+ *
7
+ * http://www.apache.org/licenses/LICENSE-2.0
8
+ *
9
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
10
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11
+ * or implied. See the License for the specific language governing permissions and limitations under
12
+ * the License.
13
+ */
14
+
15
+ import { func } from 'prop-types' ;
16
+
17
+ const TryCatchFinally = ( { try : renderTry , catch : fallBack , finally : renderFinally } ) => {
18
+ try {
19
+ return renderTry ( ) ;
20
+ } catch ( e ) {
21
+ return fallBack ( e ) ;
22
+ } finally {
23
+ renderFinally ( ) ;
24
+ }
25
+ } ;
26
+
27
+ TryCatchFinally . propTypes = {
28
+ try : func ,
29
+ catch : func ,
30
+ finally : func ,
31
+ } ;
32
+
33
+ TryCatchFinally . defaultProps = {
34
+ try : null ,
35
+ catch : ( e ) => {
36
+ throw new Error ( e ) ;
37
+ } ,
38
+ finally : null ,
39
+ } ;
40
+
41
+ export default TryCatchFinally ;
Original file line number Diff line number Diff line change 14
14
15
15
import ElseIf from './components/ElseIf' ;
16
16
import TryCatch from './components/TryCatch' ;
17
+ import TryCatchFinally from './components/TryCatchFinally' ;
17
18
import Switch from './components/Switch' ;
18
19
import Case from './components/Case' ;
19
20
import Default from './components/Default' ;
20
21
21
22
export default {
22
23
ElseIf,
23
24
TryCatch,
25
+ TryCatchFinally,
24
26
Switch,
25
27
Case,
26
28
Default,
You can’t perform that action at this time.
0 commit comments