-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathErrorHelper.coffee
More file actions
34 lines (28 loc) · 967 Bytes
/
ErrorHelper.coffee
File metadata and controls
34 lines (28 loc) · 967 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
define [
'cord!request/errors'
'cord!errors'
], (httpErrors, errors) ->
class ErrorHelper
@inject: ['translator', 'config']
getMessageHr: (error) ->
switch
when error instanceof httpErrors.InvalidResponse
message = @_getMessageHrFromInvalidResponse(error)
when error instanceof errors.TranslatedError
message = error.message
else
message = @translator.translate2(
switch
when error instanceof httpErrors.Network then 'Network error'
else 'Common error'
context: 'errors'
)
message += ": #{error.message.substring(0,255)}" if @config.debug.showMobileErrors
message
_getMessageHrFromInvalidResponse: (error) ->
###
Get correct error message from InvalidResponse error
###
switch
when error.response.body._message? then error.response.body._message
else error.message