Skip to content

Commit 34cff2c

Browse files
authored
Add deprecation warning for UnsupportedGroupTypeError And MissingGroupTypeError (#2250)
* Add deprecation warning for UnsupportedGroupTypeError And MissingGroupTypeError * Add CHANGELOG.md
1 parent d3d21b8 commit 34cff2c

File tree

6 files changed

+33
-8
lines changed

6 files changed

+33
-8
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
* [#2234](https://github.com/ruby-grape/grape/pull/2234): Remove non-utf-8 characters from format before generating JSON error - [@bschmeck](https://github.com/bschmeck).
1717
* [#2227](https://github.com/ruby-grape/grape/pull/2222): Rename "MissingGroupType" and "UnsupportedGroupType" exceptions - [@ericproulx](https://github.com/ericproulx).
1818
* [#2244](https://github.com/ruby-grape/grape/pull/2244): Fix a breaking change in `Grape::Validations` provided in 1.6.1 - [@dm1try](https://github.com/dm1try).
19+
* [#2250](https://github.com/ruby-grape/grape/pull/2250): Add deprecation warning for unsupportedgrouptypeerror and missinggrouptypeerror - [@ericproulx](https://github.com/ericproulx).
1920
* Your contribution here.
2021

2122
### 1.6.2 (2021/12/30)

lib/grape.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ module Exceptions
8181
autoload :MethodNotAllowed
8282
autoload :InvalidResponse
8383
autoload :EmptyMessageBody
84+
autoload :MissingGroupTypeError, 'grape/exceptions/missing_group_type'
85+
autoload :UnsupportedGroupTypeError, 'grape/exceptions/unsupported_group_type'
8486
end
8587
end
8688

lib/grape/exceptions/missing_group_type.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,9 @@ def initialize
1010
end
1111
end
1212

13-
Grape::Exceptions::MissingGroupTypeError = Grape::Exceptions::MissingGroupType
13+
Grape::Exceptions::MissingGroupTypeError = Class.new(Grape::Exceptions::MissingGroupType) do
14+
def initialize(*)
15+
super
16+
warn '[DEPRECATION] `Grape::Exceptions::MissingGroupTypeError` is deprecated. Use `Grape::Exceptions::MissingGroupType` instead.'
17+
end
18+
end

lib/grape/exceptions/unsupported_group_type.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,9 @@ def initialize
1010
end
1111
end
1212

13-
Grape::Exceptions::UnsupportedGroupTypeError = Grape::Exceptions::UnsupportedGroupType
13+
Grape::Exceptions::UnsupportedGroupTypeError = Class.new(Grape::Exceptions::UnsupportedGroupType) do
14+
def initialize(*)
15+
super
16+
warn '[DEPRECATION] `Grape::Exceptions::UnsupportedGroupTypeError` is deprecated. Use `Grape::Exceptions::UnsupportedGroupType` instead.'
17+
end
18+
end

spec/grape/exceptions/missing_group_type_spec.rb

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,15 @@
77
it { is_expected.to include 'group type is required' }
88
end
99

10-
describe '#alias' do
11-
subject { described_class }
10+
describe 'deprecated Grape::Exceptions::MissingGroupTypeError' do
11+
subject { Grape::Exceptions::MissingGroupTypeError.new }
1212

13-
it { is_expected.to eq(Grape::Exceptions::MissingGroupTypeError) }
13+
it 'puts a deprecation warning' do
14+
expect(Warning).to receive(:warn) do |message|
15+
expect(message).to include('`Grape::Exceptions::MissingGroupTypeError` is deprecated')
16+
end
17+
18+
subject
19+
end
1420
end
1521
end

spec/grape/exceptions/unsupported_group_type_spec.rb

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,15 @@
99
it { is_expected.to include 'group type must be Array, Hash, JSON or Array[JSON]' }
1010
end
1111

12-
describe '#alias' do
13-
subject { described_class }
12+
describe 'deprecated Grape::Exceptions::UnsupportedGroupTypeError' do
13+
subject { Grape::Exceptions::UnsupportedGroupTypeError.new }
1414

15-
it { is_expected.to eq(Grape::Exceptions::UnsupportedGroupTypeError) }
15+
it 'puts a deprecation warning' do
16+
expect(Warning).to receive(:warn) do |message|
17+
expect(message).to include('`Grape::Exceptions::UnsupportedGroupTypeError` is deprecated')
18+
end
19+
20+
subject
21+
end
1622
end
1723
end

0 commit comments

Comments
 (0)