Refactor error handling in Bumper, Media, Group, and Junction components to include contextual information
Updated error definitions in BumperErrors, MediaErrors, GroupErrors, and TemplateErrors to accept a parameter for contextual information, enhancing the clarity of error messages. Refactored related command handlers to utilize these updated error messages, ensuring that users receive specific details about the usage context when attempting to delete resources. Adjusted unit tests to verify the correctness of the new error handling logic.
This commit is contained in:
@@ -49,10 +49,14 @@ public static class TemplateErrors
|
||||
"Врезка не найдена."
|
||||
);
|
||||
|
||||
public static readonly Error JunctionInUse = Error.Conflict(
|
||||
"Templates.JunctionInUse",
|
||||
"Стык используется слотами — сначала отвяжите его."
|
||||
);
|
||||
/// <summary>Стык общий, поэтому держать его может слот чужого канала — называем какого.</summary>
|
||||
public static Error JunctionInUse(string where) =>
|
||||
Error.Conflict(
|
||||
"Templates.JunctionInUse",
|
||||
where.Length > 0
|
||||
? $"Стык используется ({where}) — сначала отвяжите его там."
|
||||
: "Стык используется слотами — сначала отвяжите его."
|
||||
);
|
||||
|
||||
public static readonly Error JunctionGroupRequired = Error.Validation(
|
||||
"Templates.JunctionGroupRequired",
|
||||
|
||||
Reference in New Issue
Block a user