-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature/31 create graphical error notifications (#118)
* created graphical error notifications * changed NetworkError to a custom error, fixed a bug where text disappears just before the notification dissapears and changed snackbar design for higher contrast with background * Fixed a bug where 'Internal server error' never gets called * added TimeoutError Co-authored-by: itsViggo <vigo@192-168-1-108.tpgi.com.au>
- Loading branch information
Showing
6 changed files
with
89 additions
and
18 deletions.
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
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
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
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
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export default class NetworkError extends Error { | ||
constructor(message = '') { | ||
super(message); | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import TimeoutError from '../interfaces/TimeoutError'; | ||
|
||
export default function timeoutPromise(ms: number, promise: Promise<Response>): Promise<Response> { | ||
return new Promise((resolve, reject) => { | ||
const timeoutId = setTimeout(() => { | ||
reject(new TimeoutError('timeout')); | ||
}, ms); | ||
promise.then( | ||
(res) => { | ||
clearTimeout(timeoutId); | ||
resolve(res); | ||
}, | ||
(err) => { | ||
clearTimeout(timeoutId); | ||
reject(err); | ||
}, | ||
); | ||
}); | ||
} |