sys-errs.sa


Generated by gen_html_sa_files from ICSI. Contact gomes@icsi.berkeley.edu for details
 
------------------------->  GNU Sather - sourcefile  <-------------------------
-- Copyright (C) 2000 by K Hopper, University of Waikato, New Zealand        --
-- This file is part of the GNU Sather library. It is free software; you may --
-- redistribute  and/or modify it under the terms of the GNU Library General --
-- Public  License (LGPL)  as published  by the  Free  Software  Foundation; --
-- either version 2 of the license, or (at your option) any later version.   --
-- This  library  is distributed  in the  hope that it will  be  useful, but --
-- WITHOUT ANY WARRANTY without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See Doc/LGPL for more details.       --
-- The license text is also available from:  Free Software Foundation, Inc., --
-- 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA                     --
-------------->  Please email comments to <bug-sather@gnu.org>  <--------------


immutable class SYS_EXCEPT < $ENUMS{SYS_EXCEPT}

immutable class SYS_EXCEPT < $ENUMS{SYS_EXCEPT} is -- This immutable class models the errors which may occur in the -- run-time library due to errors in the environment or resources. -- Version 1.0 Feb 01. Copyright K Hopper, U of Waikato -- Development History -- ------------------- -- Date Who By Detail -- ---- ------ ------ -- 27 Feb 01 kh Original include ENUM{SYS_EXCEPT} ; private const val_count : CARD := 12 ; --The next routines provide the enumeration itself. Prefix : SAME is return enum(1) end ; File_Error : SAME is return enum(2) end ; Access_Error : SAME is return enum(3) end ; Bad_Type : SAME is return enum(4) end ; Bad_Value : SAME is return enum(5) end ; Bad_Format : SAME is return enum(6) end ; Bad_Name : SAME is return enum(7) end ; Bad_Environment : SAME is return enum(8) end ; Bad_Map : SAME is return enum(9) end ; Resource_Missing : SAME is return enum(10) end ; Domain_Error : SAME is return enum(11) end ; Range_Error : SAME is return enum(12) end ; end ; -- SYS_EXCEPT

class SYS_ERROR

class SYS_ERROR is --This system class reports exceptional conditions detected in -- the Required Library either by raising the object concerned or by raising -- an informative string message. -- Version 1.0 Feb 01. Copyright K Hopper, U of Waikato -- Development History -- ------------------- -- Date Who By Detail -- ---- ------ ------ -- 27 Feb 01 kh Original private attr raise_object : BOOL ; private separator(lib : LIBCHARS) : STR is --This routine defines a global message separator for blind error. if void(lib) or lib.my_size = 0 then return "" end ; loc_res : CODE_STR := CODE_STR::create(lib) + CHAR_CODE::create(UNICODE::SPACE.card,lib) + CHAR_CODE::create(UNICODE::LATIN_CAPITAL_LETTER_I.card,lib) + CHAR_CODE::create(UNICODE::LATIN_SMALL_LETTER_N.card,lib) + CHAR_CODE::create(UNICODE::LATIN_SMALL_LETTER_I.card,lib) + CHAR_CODE::create(UNICODE::LATIN_SMALL_LETTER_T.card,lib) + CHAR_CODE::create(UNICODE::SPACE.card,lib) + CHAR_CODE::create(UNICODE::LATIN_CAPITAL_LETTER_E.card,lib) + CHAR_CODE::create(UNICODE::LATIN_SMALL_LETTER_R.card,lib) + CHAR_CODE::create(UNICODE::LATIN_SMALL_LETTER_R.card,lib) + CHAR_CODE::create(UNICODE::LATIN_SMALL_LETTER_O.card,lib) + CHAR_CODE::create(UNICODE::LATIN_SMALL_LETTER_R.card,lib) + CHAR_CODE::create(UNICODE::SPACE.card,lib) + CHAR_CODE::create(UNICODE::HYPHEN_MINUS.card,lib) + CHAR_CODE::create(UNICODE::SPACE.card,lib) ; res : STR := loc_res.tgt_str ; return res end ; create : SAME is --This routine creates a new object which either reports the error -- by raising the object concerned if the argument is true, otherwise -- a string exception is raised. me : SAME := new ; me.raise_object := false ; return me end ; -- The following two routines enable the raise state to be altered -- after creation. to_object is -- This routine channes the raise state to raise the object rather -- than a text string indication. raise_object := true end ; error(object : $OB, reason : SYS_EXCEPT,val : STR) is --This routine raises an exception in accordance with the state of -- raise_object. If a string exception is to be raised then this is composed -- from the arguments given. if raise_object then raise object else class_name : STR := STR::create ; if ~void(object) then class_name := SYS::str_for_tp(SYS::tp(object)) end ; prefix : STR := FMT::create(SYS_EXCEPT::Prefix.str,class_name).str ; loc_val : STR ; if val.size = 0 then loc_val := STR::create + ENV_CHAR::Question_Mark else loc_val := val end ; loc_reason : STR := FMT::create(reason.str,loc_val).str ; raise prefix + loc_reason end end ; file_error(object : $OB,fyle : $FILES) is --This routine raises an exception in accordance with the state of -- raise_object. If a string exception is to be raised then this is composed -- from the arguments given. if raise_object then raise object else loc_str : STR := FMT::create(SYS_EXCEPT::Prefix.str, SYS::str_for_tp(SYS::tp(object))).str ; raise loc_str + FMT::create(SYS_EXCEPT::File_Error.str, fyle.error_message,fyle.my_name).str end end ; blind_error(object : $OB,val : STR,lib : LIBCHARS) is --This routine raises a string exception for cultural initialising -- errors - where the val is some string offering a clue as to the fault. res : STR := SYS::str_for_tp(SYS::tp(object)) ; raise (res + separator(lib) + val).str end ; end ; -- SYS_ERROR