Skip to content

Commit

Permalink
added functionality to show error messages in popup
Browse files Browse the repository at this point in the history
  • Loading branch information
HemantPawar committed Mar 19, 2017
1 parent 0aabc30 commit e1df5b3
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion app/scripts.babel/lib/RequestUtils.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
import pipe from './fp';
import { appendData } from './HtmlUtils';

const errorMessage = error => (
`<div class="page-info">
<h3>Something went wrong!!!</h3>
<code>${error}</code>
</div>`
);

const checkStatus = response => (
response.ok ?
Promise.resolve(response) :
Promise.reject(new Error('status not ok', response.statusText))
);

const responseText = response => response.text();
const handleError = (error) => { console.error('oops!!!', error); }; // eslint-disable-line
const handleError = pipe(errorMessage, appendData);

export { checkStatus, responseText, handleError };

0 comments on commit e1df5b3

Please sign in to comment.