1# Copyright (c) Barefoot Networks, Inc. 2# Licensed under the Apache License, Version 2.0 (the "License") 3 4class CompilationException(Exception): 5 """Signals an error during compilation""" 6 def __init__(self, isBug, format, *message): 7 # isBug: indicates that this is a compiler bug 8 super(CompilationException, self).__init__() 9 10 assert isinstance(format, str) 11 assert isinstance(isBug, bool) 12 self.message = message 13 self.format = format 14 self.isBug = isBug 15 16 def show(self): 17 # TODO: format this message nicely 18 return self.format.format(*self.message) 19 20 21class NotSupportedException(Exception): 22 archError = " not supported by EBPF" 23 24 def __init__(self, format, *message): 25 super(NotSupportedException, self).__init__() 26 27 assert isinstance(format, str) 28 self.message = message 29 self.format = format 30 31 def show(self): 32 # TODO: format this message nicely 33 return (self.format + NotSupportedException.archError).format( 34 *self.message) 35