|
6 | 6 | using System; |
7 | 7 | using System.Collections.Generic; |
8 | 8 | using System.Data; |
| 9 | +using System.Data.Common; |
9 | 10 | using System.Data.SqlClient; |
10 | 11 | using System.Diagnostics; |
11 | 12 | using System.Diagnostics.Contracts; |
@@ -362,8 +363,8 @@ public override Topic Load(string topicKey = null, bool isRecursive = true) { |
362 | 363 | /*------------------------------------------------------------------------------------------------------------------------ |
363 | 364 | | Catch exception |
364 | 365 | \-----------------------------------------------------------------------------------------------------------------------*/ |
365 | | - catch (Exception ex) { |
366 | | - throw new Exception("Topic(s) failed to load: " + ex.Message); |
| 366 | + catch (SqlException exception) { |
| 367 | + throw new Exception($"Topic(s) failed to load: '{exception.Message}'"); |
367 | 368 | } |
368 | 369 |
|
369 | 370 | /*------------------------------------------------------------------------------------------------------------------------ |
@@ -501,8 +502,8 @@ public override Topic Load(int topicId, bool isRecursive = true) { |
501 | 502 | /*------------------------------------------------------------------------------------------------------------------------ |
502 | 503 | | Catch exception |
503 | 504 | \-----------------------------------------------------------------------------------------------------------------------*/ |
504 | | - catch (Exception ex) { |
505 | | - throw new Exception("Topics failed to load: " + ex.Message); |
| 505 | + catch (SqlException exception) { |
| 506 | + throw new Exception($"Topics failed to load: '{exception.Message}'"); |
506 | 507 | } |
507 | 508 |
|
508 | 509 | /*------------------------------------------------------------------------------------------------------------------------ |
@@ -636,8 +637,8 @@ public override Topic Load(int topicId, DateTime version) { |
636 | 637 | /*------------------------------------------------------------------------------------------------------------------------ |
637 | 638 | | Catch exception |
638 | 639 | \-----------------------------------------------------------------------------------------------------------------------*/ |
639 | | - catch (Exception ex) { |
640 | | - throw new Exception("Topics failed to load: " + ex.Message); |
| 640 | + catch (SqlException exception) { |
| 641 | + throw new Exception($"Topics failed to load: '{exception.Message}'"); |
641 | 642 | } |
642 | 643 |
|
643 | 644 | /*------------------------------------------------------------------------------------------------------------------------ |
@@ -844,8 +845,10 @@ public override int Save(Topic topic, bool isRecursive = false, bool isDraft = f |
844 | 845 | /*------------------------------------------------------------------------------------------------------------------------ |
845 | 846 | | Catch exception |
846 | 847 | \-----------------------------------------------------------------------------------------------------------------------*/ |
847 | | - catch (Exception ex) { |
848 | | - throw new Exception("Failed to save Topic " + topic.Key + " (" + topic.Id + ") via " + _connectionString + ": " + ex.Message); |
| 848 | + catch (SqlException exception) { |
| 849 | + throw new Exception( |
| 850 | + $"Failed to save Topic '{topic.Key}' ({topic.Id}) via '{_connectionString}': '{exception.Message}'" |
| 851 | + ); |
849 | 852 | } |
850 | 853 |
|
851 | 854 | /*------------------------------------------------------------------------------------------------------------------------ |
@@ -930,8 +933,10 @@ public override void Move(Topic topic, Topic target, Topic sibling) { |
930 | 933 | /*------------------------------------------------------------------------------------------------------------------------ |
931 | 934 | | Catch exception |
932 | 935 | \-----------------------------------------------------------------------------------------------------------------------*/ |
933 | | - catch (Exception ex) { |
934 | | - throw new Exception("Failed to move Topic " + topic.Key + " (" + topic.Id + ") to " + target.Key + " (" + target.Id + "): " + ex.Message); |
| 936 | + catch (SqlException exception) { |
| 937 | + throw new Exception( |
| 938 | + $"Failed to move Topic '{topic.Key}' ({topic.Id}) to '{target.Key}' ({target.Id}): '{exception.Message}'" |
| 939 | + ); |
935 | 940 | } |
936 | 941 |
|
937 | 942 | /*------------------------------------------------------------------------------------------------------------------------ |
@@ -997,8 +1002,8 @@ public override void Delete(Topic topic, bool isRecursive = false) { |
997 | 1002 | /*------------------------------------------------------------------------------------------------------------------------ |
998 | 1003 | | Catch exception |
999 | 1004 | \-----------------------------------------------------------------------------------------------------------------------*/ |
1000 | | - catch (Exception ex) { |
1001 | | - throw new Exception("Failed to delete Topic " + topic.Key + " (" + topic.Id + "): " + ex.Message); |
| 1005 | + catch (SqlException exception) { |
| 1006 | + throw new Exception($"Failed to delete Topic '{topic.Key}' ({topic.Id}): '{exception.Message}'"); |
1002 | 1007 | } |
1003 | 1008 |
|
1004 | 1009 | /*------------------------------------------------------------------------------------------------------------------------ |
@@ -1092,8 +1097,8 @@ private static string PersistRelations(Topic topic, SqlConnection connection, bo |
1092 | 1097 | /*------------------------------------------------------------------------------------------------------------------------ |
1093 | 1098 | | Catch exception |
1094 | 1099 | \-----------------------------------------------------------------------------------------------------------------------*/ |
1095 | | - catch (Exception ex) { |
1096 | | - throw new Exception("Failed to persist relationships for Topic " + topic.Key + " (" + topic.Id + "): " + ex.Message); |
| 1100 | + catch (SqlException exception) { |
| 1101 | + throw new Exception($"Failed to persist relationships for Topic '{topic.Key}' ({topic.Id}): '{exception.Message}'"); |
1097 | 1102 | } |
1098 | 1103 |
|
1099 | 1104 | /*------------------------------------------------------------------------------------------------------------------------ |
|
0 commit comments