-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added functionality to show error messages in popup
- Loading branch information
1 parent
0aabc30
commit e1df5b3
Showing
1 changed file
with
12 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }; |