Method: CF::CLI#wrap_errors

Defined in:
lib/cf/cli.rb

#wrap_errorsObject



100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
# File 'lib/cf/cli.rb', line 100

def wrap_errors
  yield
rescue CFoundry::Timeout => e
  err(e.message)
rescue Interrupt
  exit_status 130
rescue Mothership::Error
  raise
rescue UserError => e
  log_error(e)
  err e.message
rescue SystemExit
  raise
rescue UserFriendlyError => e
  err e.message
rescue CFoundry::InvalidAuthToken => e
  line
  line c("Invalid authentication token. Try logging in again with 'cf login'. If problems continue, please contact your Cloud Operator.", :warning)
rescue CFoundry::Forbidden => e
  if !$cf_asked_auth
    $cf_asked_auth = true

    line
    line c("Not authenticated! Try logging in:", :warning)

    # TODO: there's no color here; global flags not being passed
    # through (mothership bug?)
    invoke :login

    retry
  end

  log_error(e)

  err "Denied: #{e.description}"

rescue Exception => e
  log_error(e)

  msg = e.class.name
  msg << ": #{e}" unless e.to_s.empty?
  msg << "\nFor more information, see #{CF::CRASH_FILE}"
  err msg

  raise if debug?
end