@@ -14,85 +14,6 @@ namespace LibGit2Sharp.Core
14
14
{
15
15
internal class Proxy
16
16
{
17
- #region giterr_
18
-
19
- public static void giterr_set_str ( GitErrorCategory error_class , Exception exception )
20
- {
21
- if ( exception is OutOfMemoryException )
22
- {
23
- NativeMethods . giterr_set_oom ( ) ;
24
- }
25
- else
26
- {
27
- NativeMethods . giterr_set_str ( error_class , ErrorMessageFromException ( exception ) ) ;
28
- }
29
- }
30
-
31
- public static void giterr_set_str ( GitErrorCategory error_class , String errorString )
32
- {
33
- NativeMethods . giterr_set_str ( error_class , errorString ) ;
34
- }
35
-
36
- /// <summary>
37
- /// This method will take an exception and try to generate an error message
38
- /// that captures the important messages of the error.
39
- /// The formatting is a bit subjective.
40
- /// </summary>
41
- /// <param name="ex"></param>
42
- /// <returns></returns>
43
- public static string ErrorMessageFromException ( Exception ex )
44
- {
45
- StringBuilder sb = new StringBuilder ( ) ;
46
- BuildErrorMessageFromException ( sb , 0 , ex ) ;
47
- return sb . ToString ( ) ;
48
- }
49
-
50
- private static void BuildErrorMessageFromException ( StringBuilder sb , int level , Exception ex )
51
- {
52
- string indent = new string ( ' ' , level * 4 ) ;
53
- sb . AppendFormat ( "{0}{1}" , indent , ex . Message ) ;
54
-
55
- if ( ex is AggregateException )
56
- {
57
- AggregateException aggregateException = ( ( AggregateException ) ex ) . Flatten ( ) ;
58
-
59
- if ( aggregateException . InnerExceptions . Count == 1 )
60
- {
61
- sb . AppendLine ( ) ;
62
- sb . AppendLine ( ) ;
63
-
64
- sb . AppendFormat ( "{0}Contained Exception:{1}" , indent , Environment . NewLine ) ;
65
- BuildErrorMessageFromException ( sb , level + 1 , aggregateException . InnerException ) ;
66
- }
67
- else
68
- {
69
- sb . AppendLine ( ) ;
70
- sb . AppendLine ( ) ;
71
-
72
- sb . AppendFormat ( "{0}Contained Exceptions:{1}" , indent , Environment . NewLine ) ;
73
- for ( int i = 0 ; i < aggregateException . InnerExceptions . Count ; i ++ )
74
- {
75
- if ( i != 0 )
76
- {
77
- sb . AppendLine ( ) ;
78
- sb . AppendLine ( ) ;
79
- }
80
-
81
- BuildErrorMessageFromException ( sb , level + 1 , aggregateException . InnerExceptions [ i ] ) ;
82
- }
83
- }
84
- }
85
- else if ( ex . InnerException != null )
86
- {
87
- sb . AppendLine ( ) ;
88
- sb . AppendLine ( ) ;
89
- sb . AppendFormat ( "{0}Inner Exception:{1}" , indent , Environment . NewLine ) ;
90
- BuildErrorMessageFromException ( sb , level + 1 , ex . InnerException ) ;
91
- }
92
- }
93
-
94
- #endregion
95
-
96
17
#region git_blame_
97
18
98
19
public static unsafe BlameHandle git_blame_file (
@@ -924,6 +845,85 @@ public static unsafe int git_diff_num_deltas(DiffHandle diff)
924
845
925
846
#endregion
926
847
848
+ #region git_error_
849
+
850
+ public static void git_error_set_str ( GitErrorCategory error_class , Exception exception )
851
+ {
852
+ if ( exception is OutOfMemoryException )
853
+ {
854
+ NativeMethods . git_error_set_oom ( ) ;
855
+ }
856
+ else
857
+ {
858
+ NativeMethods . git_error_set_str ( error_class , ErrorMessageFromException ( exception ) ) ;
859
+ }
860
+ }
861
+
862
+ public static void git_error_set_str ( GitErrorCategory error_class , String errorString )
863
+ {
864
+ NativeMethods . git_error_set_str ( error_class , errorString ) ;
865
+ }
866
+
867
+ /// <summary>
868
+ /// This method will take an exception and try to generate an error message
869
+ /// that captures the important messages of the error.
870
+ /// The formatting is a bit subjective.
871
+ /// </summary>
872
+ /// <param name="ex"></param>
873
+ /// <returns></returns>
874
+ public static string ErrorMessageFromException ( Exception ex )
875
+ {
876
+ StringBuilder sb = new StringBuilder ( ) ;
877
+ BuildErrorMessageFromException ( sb , 0 , ex ) ;
878
+ return sb . ToString ( ) ;
879
+ }
880
+
881
+ private static void BuildErrorMessageFromException ( StringBuilder sb , int level , Exception ex )
882
+ {
883
+ string indent = new string ( ' ' , level * 4 ) ;
884
+ sb . AppendFormat ( "{0}{1}" , indent , ex . Message ) ;
885
+
886
+ if ( ex is AggregateException )
887
+ {
888
+ AggregateException aggregateException = ( ( AggregateException ) ex ) . Flatten ( ) ;
889
+
890
+ if ( aggregateException . InnerExceptions . Count == 1 )
891
+ {
892
+ sb . AppendLine ( ) ;
893
+ sb . AppendLine ( ) ;
894
+
895
+ sb . AppendFormat ( "{0}Contained Exception:{1}" , indent , Environment . NewLine ) ;
896
+ BuildErrorMessageFromException ( sb , level + 1 , aggregateException . InnerException ) ;
897
+ }
898
+ else
899
+ {
900
+ sb . AppendLine ( ) ;
901
+ sb . AppendLine ( ) ;
902
+
903
+ sb . AppendFormat ( "{0}Contained Exceptions:{1}" , indent , Environment . NewLine ) ;
904
+ for ( int i = 0 ; i < aggregateException . InnerExceptions . Count ; i ++ )
905
+ {
906
+ if ( i != 0 )
907
+ {
908
+ sb . AppendLine ( ) ;
909
+ sb . AppendLine ( ) ;
910
+ }
911
+
912
+ BuildErrorMessageFromException ( sb , level + 1 , aggregateException . InnerExceptions [ i ] ) ;
913
+ }
914
+ }
915
+ }
916
+ else if ( ex . InnerException != null )
917
+ {
918
+ sb . AppendLine ( ) ;
919
+ sb . AppendLine ( ) ;
920
+ sb . AppendFormat ( "{0}Inner Exception:{1}" , indent , Environment . NewLine ) ;
921
+ BuildErrorMessageFromException ( sb , level + 1 , ex . InnerException ) ;
922
+ }
923
+ }
924
+
925
+ #endregion
926
+
927
927
#region git_filter_
928
928
929
929
public static void git_filter_register ( string name , IntPtr filterPtr , int priority )
0 commit comments