Skip to content
This repository was archived by the owner on Feb 23, 2021. It is now read-only.

Commit 3872863

Browse files
committed
Make shareLogs handle its own errors so it doesnt require try / catching.
1 parent 13f1f28 commit 3872863

File tree

2 files changed

+26
-35
lines changed

2 files changed

+26
-35
lines changed

src/action/log.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -80,14 +80,18 @@ export async function getLogs() {
8080
* @return {Promise}
8181
*/
8282
export async function shareLogs() {
83-
if (!_Share) {
84-
throw new Error('Cannot share logs with no Share in action/log.js');
83+
try {
84+
if (!_Share) {
85+
throw new Error('Cannot share logs with no Share in action/log.js');
86+
}
87+
const logs = await getLogs();
88+
return _Share.share({
89+
title: 'Lightning App logs',
90+
message: logs,
91+
});
92+
} catch (err) {
93+
error(err.message);
8594
}
86-
const logs = await getLogs();
87-
return _Share.share({
88-
title: 'Lightning App logs',
89-
message: logs,
90-
});
9195
}
9296

9397
function pushLogs(message) {

src/view/cli.js

Lines changed: 15 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import Text from '../component/text';
88
import { BackButton, ShareButton, Button } from '../component/button';
99
import { createStyles, maxWidth } from '../component/media-query';
1010
import { color, font, breakWidth } from '../component/style';
11-
import { shareLogs, error } from '../action/log';
11+
import { shareLogs } from '../action/log';
1212

1313
//
1414
// CLI View
@@ -20,33 +20,20 @@ const styles = StyleSheet.create({
2020
},
2121
});
2222

23-
class CLIView extends Component {
24-
render() {
25-
const { store, nav } = this.props;
26-
return (
27-
<SplitBackground color={color.blackDark} bottom={color.cliBackground}>
28-
<Header separator style={styles.header}>
29-
<BackButton onPress={() => nav.goSettings()} />
30-
<Title title="Logs" />
31-
{Platform.OS === 'web' ? (
32-
<Button onPress={() => {}} />
33-
) : (
34-
<ShareButton onPress={() => this.shareLogs()} />
35-
)}
36-
</Header>
37-
<LogOutput logs={store.logs} />
38-
</SplitBackground>
39-
);
40-
}
41-
42-
async shareLogs() {
43-
try {
44-
await shareLogs();
45-
} catch (err) {
46-
error(err);
47-
}
48-
}
49-
}
23+
const CLIView = ({ store, nav }) => (
24+
<SplitBackground color={color.blackDark} bottom={color.cliBackground}>
25+
<Header separator style={styles.header}>
26+
<BackButton onPress={() => nav.goSettings()} />
27+
<Title title="Logs" />
28+
{Platform.OS === 'web' ? (
29+
<Button onPress={() => {}} />
30+
) : (
31+
<ShareButton onPress={() => shareLogs()} />
32+
)}
33+
</Header>
34+
<LogOutput logs={store.logs} />
35+
</SplitBackground>
36+
);
5037

5138
CLIView.propTypes = {
5239
store: PropTypes.object.isRequired,

0 commit comments

Comments
 (0)