cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
2304
Views
5
Helpful
1
Replies

How Handle Genie Exceptions

AJ Cruz
Level 3
Level 3

New to pyATS & Genie and kinda new to Python, I feel like I'm missing something very basic here but I can't figure out how to handle exceptions with Genie.

 

I'm dumping the mac table for specific vlans, but when I dump the table for a vlan with no mac entries my script throws this exception:

genie.metaparser.util.exceptions.SchemaEmptyParserError: Parser Output is empty

I can't figure out how to ignore this error and continue the script.

I tried:

try:
  <code>
except SchemaEmptyParserError as e:
  <handler>

as well as the full genie.metaparser.util.exceptions.SchemaEmptyParserError

But neither works.

 

1 Accepted Solution

Accepted Solutions

AJ Cruz
Level 3
Level 3

Nevermind that, I realized I had an error somewhere else when I tried to do "except Exception as e"

except Exception as e:
            if 'Parser Output is empty' in str(e):
                print(e)
            else:
                print('FATAL ERROR:')
                print(e)
                sys.exit()
seems to do the trick

View solution in original post

1 Reply 1

AJ Cruz
Level 3
Level 3

Nevermind that, I realized I had an error somewhere else when I tried to do "except Exception as e"

except Exception as e:
            if 'Parser Output is empty' in str(e):
                print(e)
            else:
                print('FATAL ERROR:')
                print(e)
                sys.exit()
seems to do the trick