Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

provide a hint for unauthorized projects.all

  • Loading branch information...
commit 8f9ed1326c44d6e2812ce645601461cd7f912642 1 parent f8c0c60
@jvdp jvdp authored
Showing with 12 additions and 2 deletions.
  1. +8 −0 lib/harvest/api/projects.rb
  2. +4 −2 lib/harvest/errors.rb
View
8 lib/harvest/api/projects.rb
@@ -4,6 +4,14 @@ class Projects < Base
api_model Harvest::Project
include Harvest::Behavior::Crud
+
+ # Retrieves all projects. Note: this requires project manager or administrator authorization.
+ # @return [Harvest::Project]
+ def all(*)
+ super
+ rescue NotFound => e
+ raise NotFound.new(e.response, e.params, "Do you have sufficient priveleges? If not, consider using time.trackable_projects instead.")
+ end
# Creates and Assigns a task to the project
#
View
6 lib/harvest/errors.rb
@@ -4,15 +4,17 @@ class InvalidCredentials < StandardError; end
class HTTPError < StandardError
attr_reader :response
attr_reader :params
+ attr_reader :hint
- def initialize(response, params = {})
+ def initialize(response, params = {}, hint = nil)
@response = response
@params = params
+ @hint = hint
super(response)
end
def to_s
- "#{self.class.to_s} : #{response.code} #{response.body}"
+ "#{self.class.to_s} : #{response.code} #{response.body}" + (hint ? "\n#{hint}" : "")
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.