-
Notifications
You must be signed in to change notification settings - Fork 34
Expand file tree
/
Copy patherrors.rb
More file actions
38 lines (32 loc) · 863 Bytes
/
errors.rb
File metadata and controls
38 lines (32 loc) · 863 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
35
36
37
38
module JsonapiCompliable
module Errors
class ValidationError < RuntimeError; end
class BadRequest < RuntimeError; end
class BadFilter < BadRequest; end
class UnsupportedPageSize < BadRequest
def initialize(size, max)
@size, @max = size, max
end
def message
"Requested page size #{@size} is greater than max supported size #{@max}"
end
end
class StatNotFound < BadRequest
def initialize(attribute, calculation)
@attribute = attribute
@calculation = calculation
end
def message
"No stat configured for calculation #{pretty(@calculation)} on attribute #{pretty(@attribute)}"
end
private
def pretty(input)
if input.is_a?(Symbol)
":#{input}"
else
"'#{input}'"
end
end
end
end
end