@@ -32,19 +32,28 @@ export default {
32
32
} )
33
33
. catch ( error => {
34
34
onError ( error )
35
- console . error ( 'ERROR: Authentication failed' )
36
- console . error ( error )
35
+ console . log ( 'ERROR: Authentication failed' )
36
+ console . log ( error . message )
37
+ let message
38
+ if ( error . message . match ( / N e t w o r k e r r o r : / ) ) {
39
+ message = {
40
+ title :'Network Error' ,
41
+ description :'Make sure you have an Internet connection. Restart and try again' ,
42
+ }
43
+ } else {
44
+ message = {
45
+ title :'Server Error' ,
46
+ description :error . message ,
47
+ }
48
+ }
49
+ channel . receive ( { data :{ type :'ERROR' , payload :{ error :message } } } )
50
+ return
37
51
} )
38
52
39
53
if ( ! result || ! result . data ) {
40
- // TODO handle failed authentication
41
- console . error ( 'ERROR: Connection' )
42
- const error = {
43
- title :'Connection Failed' ,
44
- description :
45
- 'Either our server is having issues or you may not be connected to the internet. Try checking your connection and restarting the application. ' ,
46
- }
47
- channel . receive ( { data :{ type :'ERROR' , payload :{ error} } } )
54
+ const error = new Error ( 'Authentication request responded with no data' )
55
+ console . log ( error )
56
+ onError ( error )
48
57
return
49
58
}
50
59
const { token} = result . data . editorLogin