error for bad md extensions

This commit is contained in:
Lachlan Kermode
2019-01-04 14:04:15 +00:00
parent 7b44dc8751
commit f32f96cae3
2 changed files with 16 additions and 12 deletions

View File

@@ -12,6 +12,9 @@ class Md extends React.Component {
fetch(this.props.path)
.then(resp => resp.text())
.then(text => {
if (text.length <= 0)
throw new Error()
this.setState({ md: marked(text) })
})
.catch(err => {
@@ -34,7 +37,7 @@ class Md extends React.Component {
Md.propTypes = {
loader: PropTypes.func,
unloader: PropTypes.func,
unloader: PropTypes.func.isRequired,
path: PropTypes.string.isRequired
}

View File

@@ -7,15 +7,21 @@ import NoSource from './presentational/NoSource'
// TODO: move render functions into presentational components
function SourceOverlay ({ source, onCancel }) {
function renderError() {
return (
<NoSource failedUrls={["NOT ALL SOURCES AVAILABLE IN APPLICATION YET"]} />
)
}
function renderImage(path) {
return (
<div className='source-image-container'>
<Img
className='source-image'
src={path}
loader={<Spinner />}
unloader={<NoSource failedUrls={source.paths} />}
/>
<Img
className='source-image'
src={path}
loader={<Spinner />}
unloader={<NoSource failedUrls={source.paths} />}
/>
</div>
)
}
@@ -45,11 +51,6 @@ function SourceOverlay ({ source, onCancel }) {
)
}
function renderError() {
return (
<NoSource failedUrls={["NOT ALL SOURCES AVAILABLE IN APPLICATION YET"]} />
)
}
function renderNoSupport(ext) {
return (