File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -796,22 +796,36 @@ public XmlSchema ValidateSchema(DataGridViewRow row, string filename)
796796 public XmlSchema LoadSchema ( string filename )
797797 {
798798 if ( string . IsNullOrEmpty ( filename ) ) return null ;
799- using ( var r = new XmlTextReader ( filename , new NameTable ( ) ) )
799+ try
800800 {
801- return XmlSchema . Read ( r , ( sender , args ) =>
801+ using ( var r = new XmlTextReader ( filename , new NameTable ( ) ) )
802802 {
803- if ( args . Exception is XmlSchemaException se )
803+ return XmlSchema . Read ( r , ( sender , args ) =>
804804 {
805- LogError ( $ "{ args . Message } See line { se . LineNumber } pos { se . LinePosition } of { se . SourceUri } ") ;
806- }
807- else
808- {
809- LogError ( args . Message ) ;
810- }
811- } ) ;
805+ if ( args . Exception is XmlSchemaException se )
806+ {
807+ this . LogError ( $ "{ args . Message } See line { se . LineNumber } pos { se . LinePosition } of { se . SourceUri } ") ;
808+ }
809+ else
810+ {
811+ this . LogError ( args . Message ) ;
812+ }
813+ } ) ;
814+ }
815+ }
816+ catch ( XmlException xe )
817+ {
818+ // The files that do not meet the basic XML structure,
819+ // such as empty files or files with unclosed tags
820+ this . LogError ( $ "{ xe . Message } See line { xe . LineNumber } pos { xe . LinePosition } of { xe . SourceUri } ") ;
821+ return null ;
822+ }
823+ catch ( Exception e )
824+ {
825+ this . LogError ( e . Message ) ;
826+ return null ;
812827 }
813828 }
814-
815829 }
816830
817831 class SchemaDialogNewRow : SchemaDialogCommand
You can’t perform that action at this time.
0 commit comments