44using CSUtilities . IO ;
55using CSUtilities . Text ;
66using System ;
7- using System . Collections . Generic ;
87using System . IO ;
8+ using System . Runtime . CompilerServices ;
99using System . Text ;
1010
1111namespace ACadSharp . IO . DWG
@@ -41,7 +41,6 @@ public static IDwgStreamReader GetStreamHandler(ACadVersion version, Stream stre
4141 switch ( version )
4242 {
4343 case ACadVersion . Unknown :
44- throw new Exception ( ) ;
4544 case ACadVersion . MC0_0 :
4645 case ACadVersion . AC1_2 :
4746 case ACadVersion . AC1_4 :
@@ -52,7 +51,7 @@ public static IDwgStreamReader GetStreamHandler(ACadVersion version, Stream stre
5251 case ACadVersion . AC1004 :
5352 case ACadVersion . AC1006 :
5453 case ACadVersion . AC1009 :
55- throw new NotSupportedException ( $ "Dwg version not supported: { version } " ) ;
54+ throw new CadNotSupportedException ( version ) ;
5655 case ACadVersion . AC1012 :
5756 case ACadVersion . AC1014 :
5857 reader = new DwgStreamReaderAC12 ( stream , resetPositon ) ;
@@ -72,7 +71,7 @@ public static IDwgStreamReader GetStreamHandler(ACadVersion version, Stream stre
7271 reader = new DwgStreamReaderAC24 ( stream , resetPositon ) ;
7372 break ;
7473 default :
75- throw new NotSupportedException ( $ "Dwg version not supported: { version } " ) ;
74+ throw new CadNotSupportedException ( ) ;
7675 }
7776
7877 if ( encoding != null )
@@ -105,7 +104,7 @@ public static Dictionary<string, object> Explore(IDwgStreamReader reader)
105104 tryGetValue ( reader , values , reader . ReadRawChar ) ;
106105 tryGetValue ( reader , values , reader . ReadRawLong ) ;
107106 tryGetValue ( reader , values , reader . Read2RawDouble ) ;
108-
107+
109108 tryGetValue ( reader , values , reader . HandleReference ) ;
110109
111110 tryGetValue ( reader , values , reader . ReadTextUnicode ) ;
@@ -271,7 +270,7 @@ public short ReadBitShort()
271270 value = 256 ;
272271 break ;
273272 default :
274- throw new Exception ( ) ;
273+ throw this . throwException ( ) ;
275274 }
276275 return value ;
277276 }
@@ -308,7 +307,7 @@ public int ReadBitLong()
308307 break ;
309308 default :
310309 //11 : not used
311- throw new Exception ( ) ;
310+ throw new Exception ( "Failed to read ReadBitLong" ) ;
312311 }
313312 return value ;
314313 }
@@ -344,7 +343,7 @@ public double ReadBitDouble()
344343 value = 0.0 ;
345344 break ;
346345 default :
347- throw new Exception ( ) ;
346+ throw this . throwException ( ) ;
348347 }
349348
350349 return value ;
@@ -824,7 +823,7 @@ public double ReadBitDoubleWithDefault(double def)
824823 case 3 :
825824 return this . ReadDouble ( ) ;
826825 default :
827- throw new Exception ( ) ;
826+ throw this . throwException ( ) ;
828827 }
829828 }
830829
@@ -859,7 +858,6 @@ public TimeSpan ReadTimeSpan()
859858 if ( hours < 0 || hours > TimeSpan . MaxValue . TotalHours || milliseconds < 0 || milliseconds > TimeSpan . MaxValue . TotalMilliseconds )
860859 {
861860 return TimeSpan . FromHours ( 0 ) + TimeSpan . FromMilliseconds ( 0 ) ;
862-
863861 }
864862
865863 return TimeSpan . FromHours ( hours ) + TimeSpan . FromMilliseconds ( milliseconds ) ;
@@ -963,6 +961,11 @@ protected byte applyShiftToLasByte()
963961 return ( byte ) ( ( uint ) value | ( byte ) ( ( uint ) this . _lastByte >> 8 - this . BitShift ) ) ;
964962 }
965963
964+ protected DwgException throwException ( [ CallerMemberName ] string callerName = null )
965+ {
966+ return new DwgException ( $ "Failed to read { callerName } ") ;
967+ }
968+
966969 private void applyShiftToArr ( int length , byte [ ] arr )
967970 {
968971 //Empty Stream
0 commit comments