4
4
using CSUtilities . IO ;
5
5
using CSUtilities . Text ;
6
6
using System ;
7
- using System . Collections . Generic ;
8
7
using System . IO ;
8
+ using System . Runtime . CompilerServices ;
9
9
using System . Text ;
10
10
11
11
namespace ACadSharp . IO . DWG
@@ -41,7 +41,6 @@ public static IDwgStreamReader GetStreamHandler(ACadVersion version, Stream stre
41
41
switch ( version )
42
42
{
43
43
case ACadVersion . Unknown :
44
- throw new Exception ( ) ;
45
44
case ACadVersion . MC0_0 :
46
45
case ACadVersion . AC1_2 :
47
46
case ACadVersion . AC1_4 :
@@ -52,7 +51,7 @@ public static IDwgStreamReader GetStreamHandler(ACadVersion version, Stream stre
52
51
case ACadVersion . AC1004 :
53
52
case ACadVersion . AC1006 :
54
53
case ACadVersion . AC1009 :
55
- throw new NotSupportedException ( $ "Dwg version not supported: { version } " ) ;
54
+ throw new CadNotSupportedException ( version ) ;
56
55
case ACadVersion . AC1012 :
57
56
case ACadVersion . AC1014 :
58
57
reader = new DwgStreamReaderAC12 ( stream , resetPositon ) ;
@@ -72,7 +71,7 @@ public static IDwgStreamReader GetStreamHandler(ACadVersion version, Stream stre
72
71
reader = new DwgStreamReaderAC24 ( stream , resetPositon ) ;
73
72
break ;
74
73
default :
75
- throw new NotSupportedException ( $ "Dwg version not supported: { version } " ) ;
74
+ throw new CadNotSupportedException ( ) ;
76
75
}
77
76
78
77
if ( encoding != null )
@@ -105,7 +104,7 @@ public static Dictionary<string, object> Explore(IDwgStreamReader reader)
105
104
tryGetValue ( reader , values , reader . ReadRawChar ) ;
106
105
tryGetValue ( reader , values , reader . ReadRawLong ) ;
107
106
tryGetValue ( reader , values , reader . Read2RawDouble ) ;
108
-
107
+
109
108
tryGetValue ( reader , values , reader . HandleReference ) ;
110
109
111
110
tryGetValue ( reader , values , reader . ReadTextUnicode ) ;
@@ -271,7 +270,7 @@ public short ReadBitShort()
271
270
value = 256 ;
272
271
break ;
273
272
default :
274
- throw new Exception ( ) ;
273
+ throw this . throwException ( ) ;
275
274
}
276
275
return value ;
277
276
}
@@ -308,7 +307,7 @@ public int ReadBitLong()
308
307
break ;
309
308
default :
310
309
//11 : not used
311
- throw new Exception ( ) ;
310
+ throw new Exception ( "Failed to read ReadBitLong" ) ;
312
311
}
313
312
return value ;
314
313
}
@@ -344,7 +343,7 @@ public double ReadBitDouble()
344
343
value = 0.0 ;
345
344
break ;
346
345
default :
347
- throw new Exception ( ) ;
346
+ throw this . throwException ( ) ;
348
347
}
349
348
350
349
return value ;
@@ -824,7 +823,7 @@ public double ReadBitDoubleWithDefault(double def)
824
823
case 3 :
825
824
return this . ReadDouble ( ) ;
826
825
default :
827
- throw new Exception ( ) ;
826
+ throw this . throwException ( ) ;
828
827
}
829
828
}
830
829
@@ -859,7 +858,6 @@ public TimeSpan ReadTimeSpan()
859
858
if ( hours < 0 || hours > TimeSpan . MaxValue . TotalHours || milliseconds < 0 || milliseconds > TimeSpan . MaxValue . TotalMilliseconds )
860
859
{
861
860
return TimeSpan . FromHours ( 0 ) + TimeSpan . FromMilliseconds ( 0 ) ;
862
-
863
861
}
864
862
865
863
return TimeSpan . FromHours ( hours ) + TimeSpan . FromMilliseconds ( milliseconds ) ;
@@ -963,6 +961,11 @@ protected byte applyShiftToLasByte()
963
961
return ( byte ) ( ( uint ) value | ( byte ) ( ( uint ) this . _lastByte >> 8 - this . BitShift ) ) ;
964
962
}
965
963
964
+ protected DwgException throwException ( [ CallerMemberName ] string callerName = null )
965
+ {
966
+ return new DwgException ( $ "Failed to read { callerName } ") ;
967
+ }
968
+
966
969
private void applyShiftToArr ( int length , byte [ ] arr )
967
970
{
968
971
//Empty Stream
0 commit comments