@@ -71,7 +71,7 @@ pub fn dynamic_compile(
7171 }
7272 }
7373 CompileOutput :: Valid ( v) => ( v, Vec :: new ( ) ) ,
74- _ => unreachable ! ( ) ,
74+ o => return o ,
7575 } ;
7676 check_layers ( & data, & mut errors) ;
7777 if errors. is_empty ( ) {
@@ -2023,11 +2023,22 @@ impl<'a> ExecPass<'a> {
20232023 _ => None ,
20242024 } ) {
20252025 let cell_id = self . execute_cell ( vid, input. args , Some ( "TOP" ) ) ;
2026- let layers = klayout_lyp:: from_reader ( BufReader :: new (
2027- std:: fs:: File :: open ( input. lyp_file ) . unwrap ( ) ,
2028- ) )
2029- . unwrap ( )
2030- . into ( ) ;
2026+ let layers = if let Ok ( layers) = std:: fs:: File :: open ( input. lyp_file )
2027+ . map_err ( |_| ( ) )
2028+ . and_then ( |f| klayout_lyp:: from_reader ( BufReader :: new ( f) ) . map_err ( |_| ( ) ) )
2029+ {
2030+ layers. into ( )
2031+ } else {
2032+ return CompileOutput :: StaticErrors ( StaticErrorCompileOutput {
2033+ errors : vec ! [ StaticError {
2034+ span: Span {
2035+ path: self . ast[ & vec![ ] ] . path. clone( ) ,
2036+ span: cfgrammar:: Span :: new( 0 , 0 ) ,
2037+ } ,
2038+ kind: StaticErrorKind :: InvalidLyp ,
2039+ } ] ,
2040+ } ) ;
2041+ } ;
20312042 if self . errors . is_empty ( ) {
20322043 CompileOutput :: Valid ( CompiledData {
20332044 cells : self . compiled_cells ,
@@ -4050,6 +4061,9 @@ pub enum StaticErrorKind {
40504061 /// Error during parsing.
40514062 #[ error( "error during parsing" ) ]
40524063 ParseError ,
4064+ /// Invalid LYP file.
4065+ #[ error( "invalid LYP file" ) ]
4066+ InvalidLyp ,
40534067}
40544068
40554069#[ derive( Debug , Clone , Serialize , Deserialize ) ]
0 commit comments