Sha256: b650b303d271bb58897b71ae56ba926a778eda9f710e3ce286cf397c22bc4e69

Contents?: true

Size: 921 Bytes

Versions: 12

Compression:

Stored size: 921 Bytes

Contents

class window.Errors

  constructor: (response)->
    if response.status == 401
      if response.getResponseHeader('X-Credentials') == 'Missing Credentials'
        @missingCredentials = true
      else if response.getResponseHeader('X-Credentials') == 'Invalid Credentials'
        @invalidCredentials = true
      else if response.getResponseHeader('X-Credentials') == 'Oauth'
        @oauthLocation = response.getResponseHeader('Location')
      else
        message = response.responseText ? "You are not authorized"
        @errors = {base: [message]}
    else
      @errors = JSON.parse(response.responseText)

  renderToAlert: ->
    sentences = []
    for attribute, messages of @errors
      if attribute == "base"
        sentences.push messages[0]
      else
        sentences.push "#{attribute} #{messages[0]}"
    alertify.error sentences.join(".\n")

Errors.fromResponse = (response)-> new Errors(response)

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
houston-core-0.8.4 app/assets/javascripts/houston/core/errors.coffee
houston-core-0.8.3 app/assets/javascripts/houston/core/errors.coffee
houston-core-0.8.2 app/assets/javascripts/houston/core/errors.coffee
houston-core-0.8.1 app/assets/javascripts/houston/core/errors.coffee
houston-core-0.8.0 app/assets/javascripts/houston/core/errors.coffee
houston-core-0.8.0.pre2 app/assets/javascripts/houston/core/errors.coffee
houston-core-0.8.0.pre app/assets/javascripts/houston/core/errors.coffee
houston-core-0.7.0 app/assets/javascripts/houston/core/errors.coffee
houston-core-0.7.0.beta4 app/assets/javascripts/houston/core/errors.coffee
houston-core-0.7.0.beta3 app/assets/javascripts/houston/core/errors.coffee
houston-core-0.7.0.beta2 app/assets/javascripts/houston/core/errors.coffee
houston-core-0.7.0.beta app/assets/javascripts/houston/core/errors.coffee