Skip to content

Commit 003fad6

Browse files
committed
modify behavior of function according to new agreed one
1 parent 1400422 commit 003fad6

2 files changed

Lines changed: 18 additions & 14 deletions

File tree

web/api/report_server.thrift

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -594,26 +594,26 @@ service codeCheckerDBAccess {
594594
//============================================
595595

596596
// Stores the given FilterPreset with the given id
597-
// If the preset exists, it overwrites the name, and all preset values
598-
// if the preset does not exist yet, it creates it with
599-
// if the id is -1 a new preset filter is created
600-
// the filter preset name must be unique.
601-
// An error must be thrown if another preset exists with the same name.
602-
// The encoding of the name must be unicode. (whitespaces allowed?)
603-
// Returns: the id of the modified or created preset, -1 in case of error
597+
// If the preset exists with the given id, it overwrites the name, and all preset values
598+
// if the preset does not exist yet, throws and error
599+
// if the id is -1 a new preset filter is created and the id of the new preset is returned.
600+
// If a preset with that name already existed, it throws an error. Thus the filter preset name must be unique.
601+
// The encoding of the name must be unicode. (whitespaces allowed)
602+
// Maximum filter preset name 50
603+
// Returns: the id of the modified or created preset
604604
// PERMISSION: PRODUCT_ADMIN
605605
i64 storeFilterPreset(1: FilterPreset preset)
606606
throws (1: codechecker_api_shared.RequestFailed requestError);
607607

608608
// Returns the FilterPreset identified by id
609-
// Returns -1 in case there is no preset with the given id
609+
// Throws and error in case there is no preset with the given id
610610
// PERMISSION: PRODUCT_VIEW
611611
FilterPreset getFilterPreset(1: i64 id)
612612
throws (1: codechecker_api_shared.RequestFailed requestError);
613613

614-
// Removes the filterpreset with the given id
614+
// Removes the filter preset with the given id
615615
// returns the id of the filter preset removed
616-
// and -1 in case of error.
616+
// throws an error if the preset with the given id does not exist.
617617
// PERMISSION: PRODUCT_ADMIN
618618
i64 deleteFilterPreset(1: i64 id)
619619
throws (1: codechecker_api_shared.RequestFailed requestError);

web/server/codechecker_server/api/report_server.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1751,7 +1751,6 @@ def to_jsonable(obj):
17511751

17521752
session.add(preset_entry)
17531753
session.commit()
1754-
print(f"Created new filter preset with name '{name}' and id {preset_entry.id}")
17551754
return preset_entry.id
17561755

17571756
# case for updating an existing preset
@@ -1767,7 +1766,6 @@ def to_jsonable(obj):
17671766
preset_entry.preset_name = name
17681767
preset_entry.report_filter = report_filter
17691768
session.commit()
1770-
print(f"Updated filter preset id {id} with name '{name}'")
17711769
return preset_entry.id
17721770
except Exception as ex:
17731771
session.rollback()
@@ -1790,8 +1788,12 @@ def deleteFilterPreset(self, preset_id):
17901788
with DBSession(self._Session) as session:
17911789
preset = session.query(FilterPreset). \
17921790
filter(FilterPreset.id == preset_id).one_or_none()
1791+
17931792
if not preset:
1794-
return -1
1793+
raise codechecker_api_shared.ttypes.RequestFailed(
1794+
codechecker_api_shared.ttypes.ErrorCode.DATABASE,
1795+
f"No filter preset found with id {preset_id}!")
1796+
17951797

17961798
session.query(FilterPreset) \
17971799
.filter(FilterPreset.id == preset_id) \
@@ -1822,7 +1824,9 @@ def getFilterPreset(self, preset_id):
18221824
)
18231825

18241826
if preset is None:
1825-
return -1
1827+
raise codechecker_api_shared.ttypes.RequestFailed(
1828+
codechecker_api_shared.ttypes.ErrorCode.DATABASE,
1829+
f"No filter preset found with id {preset_id}!")
18261830

18271831
# Pre creation of variables that are objects themselves.
18281832
report_filter = tranform_rf_db_to_thrift(preset.report_filter)

0 commit comments

Comments
 (0)