graph_exc.sa


Generated by gen_html_sa_files from ICSI. Contact gomes@icsi.berkeley.edu for details
 
---------------------------> Sather 1.1 source file <--------------------------
-- Author: Benedict A. Gomes <gomes@samosa.ICSI.Berkeley.EDU>
-- Copyright (C) 1995, International Computer Science Institute
-- $Id: graph_exc.sa,v 1.3 1996/04/09 10:05:41 borisv Exp $
--
-- COPYRIGHT NOTICE: This code is provided WITHOUT ANY WARRANTY
-- and is subject to the terms of the SATHER LIBRARY GENERAL PUBLIC
-- LICENSE contained in the file: Sather/Doc/License of the
-- Sather distribution. The license is also available from ICSI,
-- 1947 Center St., Suite 600, Berkeley CA 94704, USA.


class GRAPH_EXC < $STR

class GRAPH_EXC < $STR is -- The graph exception class. A single class is used for all library -- graph exceptions for simplicity and sanity. It may make -- sense to split this class up at some future point -- The error states are denoted by the constants beginning with err_ -- err should be set to one of these -- -- Usage: -- raise #DIGRAPH_EXC{INT}(self,"foo",g,"bad graph").missing_edge_labels; -- -- protect -- ... -- when $STR then #OUT+exception.str; end; -- You can also check for more detailed information in the exception -- object. In general, you can compare the "err" flag to see which -- of the constants it is set to. -- switch exception.err -- when exception.err_missing_edge_labels then -- do somethin -- when exception.err_missing_node_labels then ... -- else ... end; const err_missing_edge_labels: STR := "All edges not labelled"; const err_missing_node_labels: STR := "All nodes not labelled"; const err_not_specified: STR := "No error specified"; readonly attr err: STR; -- Err should be set to one of the constant err_ strings readonly attr in_object: $OB; -- Object in which error occurs. readonly attr routine_name: STR; readonly attr message: STR; readonly attr graph: $STR; create(inobj: $OB,rout: STR,g:$STR,msg: STR): SAME is res ::= new; res.in_object := inobj; res.routine_name := rout; res.message := msg; res.graph := g; res.err := err_not_specified; return res; end; missing_edge_labels: SAME is err:=err_missing_edge_labels; return self end; -- All edges were required to be labelled (possibly with weights) -- but some labels were missing missing_node_labels: SAME is err:=err_missing_node_labels; return self end; -- All nodes were required to be labelled (possibly weighted) -- but some were missing print(file: $OSTREAM) is file+ "\n**************************************************\n"; file+ "Graph Exception in routine "+routine_name+"\n"; file+"Error:"+err+"\n"; file+"\n"+message+"\n"; if ~void(graph) then file+graph.str; end; file+"\n**************************************************\n"; end; str: STR is s::= #STR_STREAM; print(s); return s.str; end; end;