Skip to content

Commit 8dbe49e

Browse files
committed
use InvalidParameterError for bulk errors, adjusts note
1 parent f92f38e commit 8dbe49e

File tree

9 files changed

+26
-16
lines changed

9 files changed

+26
-16
lines changed

lib/superset/chart/bulk_delete.rb

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
# frozen_string_literal: true
2-
# TODO: the gui delete has a confirmation step, this does not. Potentially add a confirm_delete parameter to the constructor
3-
# that would ensure that all charts belong to an expected dashboard before deleting. ( not sure if this is a good idea )
4-
2+
# TODO: the gui delete has a confirmation step, this API call does not.
3+
# Potentially we could add a confirm_delete parameter to the constructor that would ensure that all charts either
4+
# 1 belong to only an expected dashboard before deleting
5+
# 2 or do not belong to any dashboards
6+
# ( not sure if this needed at this point )
57

68
module Superset
79
module Chart

lib/superset/chart/delete.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ def initialize(chart_id: )
1010
end
1111

1212
def perform
13-
raise "Error: chart_id integer is required" unless chart_id.present? && chart_id.is_a?(Integer)
13+
raise InvalidParameterError, "chart_id integer is required" unless chart_id.present? && chart_id.is_a?(Integer)
1414

1515
logger.info("Attempting to delete chart with id: #{chart_id}")
1616
response

lib/superset/dashboard/bulk_delete.rb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
# frozen_string_literal: true
2-
# TODO: the gui delete has a confirmation step, this does not. Potentially add a confirm_delete parameter to the constructor
3-
# that would ensure that no charts belong to a dashboard before deleting
2+
3+
# TODO: the gui delete has a confirmation step, this API call does not.
4+
# Potentially we could add a confirm_delete parameter to the constructor that would ensure that all dashboards either
5+
# 1 have an expected set of charts or filters before deleting
6+
# 2 or do not have any charts or filters linked to them
7+
# ( not sure if this needed at this point )
48

59
module Superset
610
module Dashboard

lib/superset/dashboard/delete.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def initialize(dashboard_id: , confirm_zero_charts: true)
1212
end
1313

1414
def perform
15-
raise "Error: dashboard_id integer is required" unless dashboard_id.present? && dashboard_id.is_a?(Integer)
15+
raise InvalidParameterError, "dashboard_id integer is required" unless dashboard_id.present? && dashboard_id.is_a?(Integer)
1616

1717
confirm_zero_charts_on_dashboard if confirm_zero_charts
1818

lib/superset/dataset/bulk_delete.rb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
# frozen_string_literal: true
2-
# TODO: the gui delete has a confirmation step, this does not. Potentially add a confirm_delete parameter to the constructor
3-
# that would ensure that no charts point to a dataset before deleting
2+
3+
# TODO: the gui delete has a confirmation step, this API call does not.
4+
# Potentially we could add a confirm_delete parameter to the constructor that would ensure that all datasets either
5+
# 1 belong to only an expected charts or filters before deleting
6+
# 2 or do not belong to any charts or filters
7+
# ( not sure if this needed at this point )
48

59
module Superset
610
module Dataset

lib/superset/dataset/delete.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ def initialize(dataset_id: )
1010
end
1111

1212
def perform
13-
raise "Error: dataset_id integer is required" unless dataset_id.present? && dataset_id.is_a?(Integer)
13+
raise InvalidParameterError, "dataset_id integer is required" unless dataset_id.present? && dataset_id.is_a?(Integer)
1414

1515
logger.info("Attempting to delete dataset with id: #{dataset_id}")
1616
response

spec/superset/chart/delete_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@
1414
let(:chart_id) { nil }
1515

1616
it 'raises an error' do
17-
expect { subject.perform }.to raise_error(RuntimeError, "Error: chart_id integer is required")
17+
expect { subject.perform }.to raise_error(Superset::Request::InvalidParameterError, "chart_id integer is required")
1818
end
1919
end
2020

2121
context 'when chart_id is not an integer' do
2222
let(:chart_id) { 'string' }
2323

2424
it 'raises an error' do
25-
expect { subject.perform }.to raise_error(RuntimeError, "Error: chart_id integer is required")
25+
expect { subject.perform }.to raise_error(Superset::Request::InvalidParameterError, "chart_id integer is required")
2626
end
2727
end
2828

spec/superset/dashboard/delete_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@
1414
let(:dashboard_id) { nil }
1515

1616
it 'raises an error' do
17-
expect { subject.perform }.to raise_error(RuntimeError, "Error: dashboard_id integer is required")
17+
expect { subject.perform }.to raise_error(Superset::Request::InvalidParameterError, "dashboard_id integer is required")
1818
end
1919
end
2020

2121
context 'when dashboard_id is not an integer' do
2222
let(:dashboard_id) { 'string' }
2323

2424
it 'raises an error' do
25-
expect { subject.perform }.to raise_error(RuntimeError, "Error: dashboard_id integer is required")
25+
expect { subject.perform }.to raise_error(Superset::Request::InvalidParameterError, "dashboard_id integer is required")
2626
end
2727
end
2828

spec/superset/dataset/delete_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@
1414
let(:dataset_id) { nil }
1515

1616
it 'raises an error' do
17-
expect { subject.perform }.to raise_error(RuntimeError, "Error: dataset_id integer is required")
17+
expect { subject.perform }.to raise_error(Superset::Request::InvalidParameterError, "dataset_id integer is required")
1818
end
1919
end
2020

2121
context 'when dataset_id is not an integer' do
2222
let(:dataset_id) { 'string' }
2323

2424
it 'raises an error' do
25-
expect { subject.perform }.to raise_error(RuntimeError, "Error: dataset_id integer is required")
25+
expect { subject.perform }.to raise_error(Superset::Request::InvalidParameterError, "dataset_id integer is required")
2626
end
2727
end
2828

0 commit comments

Comments
 (0)