Skip to content

Commit fa220f6

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

2 files changed

Lines changed: 18 additions & 12 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 & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1790,8 +1790,12 @@ def deleteFilterPreset(self, preset_id):
17901790
with DBSession(self._Session) as session:
17911791
preset = session.query(FilterPreset). \
17921792
filter(FilterPreset.id == preset_id).one_or_none()
1793+
17931794
if not preset:
1794-
return -1
1795+
raise codechecker_api_shared.ttypes.RequestFailed(
1796+
codechecker_api_shared.ttypes.ErrorCode.DATABASE,
1797+
f"No filter preset found with id {preset_id}!")
1798+
17951799

17961800
session.query(FilterPreset) \
17971801
.filter(FilterPreset.id == preset_id) \
@@ -1822,7 +1826,9 @@ def getFilterPreset(self, preset_id):
18221826
)
18231827

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

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

0 commit comments

Comments
 (0)