diff --git a/examples/path_requests_run.py b/examples/path_requests_run.py index f4cdfe58..8eb580b3 100755 --- a/examples/path_requests_run.py +++ b/examples/path_requests_run.py @@ -436,7 +436,11 @@ def main(args): print(rqs) print('\x1b[1;34;40m' + f'Computing all paths with constraints' + '\x1b[0m') - pths = compute_path_dsjctn(network, equipment, rqs, dsjn) + try: + pths = compute_path_dsjctn(network, equipment, rqs, dsjn) + except DisjunctionError as this_e: + print(f'{ansi_escapes.red}Disjunction error:{ansi_escapes.reset} {this_e}') + exit(1) print('\x1b[1;34;40m' + f'Propagating on selected path' + '\x1b[0m') propagatedpths, reversed_pths, reversed_propagatedpths = \ diff --git a/gnpy/core/exceptions.py b/gnpy/core/exceptions.py index 655dc196..2862dfbc 100644 --- a/gnpy/core/exceptions.py +++ b/gnpy/core/exceptions.py @@ -21,3 +21,5 @@ class NetworkTopologyError(ConfigurationError): class ServiceError(Exception): '''Service of user-provided request is wrong''' +class DisjunctionError(ServiceError): + '''Disjunction of user-provided request can not be satisfied''' diff --git a/gnpy/core/request.py b/gnpy/core/request.py index c69d643f..7ba2d40b 100644 --- a/gnpy/core/request.py +++ b/gnpy/core/request.py @@ -24,7 +24,7 @@ from gnpy.core.service_sheet import convert_service_sheet, Request_element, Elem from gnpy.core.elements import Transceiver, Roadm, Edfa, Fused from gnpy.core.utils import db2lin, lin2db from gnpy.core.info import create_input_spectral_information, SpectralInformation, Channel, Power -from gnpy.core.exceptions import ServiceError +from gnpy.core.exceptions import ServiceError, DisjunctionError from copy import copy, deepcopy from csv import writer from math import ceil @@ -878,7 +878,7 @@ def compute_path_dsjctn(network, equipment, pathreqlist, disjunctions_list): LOGGER.critical(msg) print(f'{msg}\nComputation stopped.') # TODO in this case: replay step 5 with the candidate without constraints - exit() + raise DisjunctionError(msg) # for i in disjunctions_list: # print(i.disjunction_id)