improved error handling/messages
git-svn-id: https://projects.brucker.ch/su4sml/svn/su4sml/trunk@8373 3260e6d1-4efc-4170-b0a7-36055960796d
This commit is contained in:
parent
9ea9efc2f0
commit
450aa6f33c
|
@ -6,7 +6,7 @@
|
|||
* This file is part of su4sml.
|
||||
*
|
||||
* Copyright (c) 2005-2007 ETH Zurich, Switzerland
|
||||
* (c) 2008-2009 Achim D. Brucker, Germany
|
||||
* 2008-2009 Achim D. Brucker, Germany
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
|
@ -338,18 +338,62 @@ fun cond_list (path,sign,[]) =
|
|||
fun guard_list (context,[]) = []
|
||||
| guard_list (context,(name,expr)::tail) = Guard (context,name,expr)::guard_list (context,tail)
|
||||
|
||||
|
||||
|
||||
|
||||
(* RETURN: string *)
|
||||
fun cxt_list2string ([]) = ""
|
||||
| cxt_list2string ((Empty_context(s,t))::tail) =
|
||||
"empty: "^(Ocl2String.ocl2string false t)^"\n"^(cxt_list2string tail)
|
||||
| cxt_list2string ((Inv(p,s,t))::tail) =
|
||||
"inv: "^(Ocl2String.ocl2string false t)^"\n"^(cxt_list2string tail)
|
||||
| cxt_list2string ((Attr(p,ty,a,t))::tail) =
|
||||
"attr_or_assoc "^(Ocl2String.ocl2string false t)^"\n"^(cxt_list2string tail)
|
||||
| cxt_list2string ((Cond(p,s,l,ty,c,so,t))::tail) =
|
||||
"condition: "^(Ocl2String.ocl2string false t)^"\n"^(cxt_list2string tail)
|
||||
| cxt_list2string ((Guard(p,so,t))::tail) =
|
||||
"guard: "^(Ocl2String.ocl2string false t)^"\n"^(cxt_list2string tail)
|
||||
(*
|
||||
fun cxt_list2string ([]) = ""
|
||||
| cxt_list2string ((Empty_context(s,t))::tail) =
|
||||
"empty: "^(Ocl2String.ocl2string false t)^"\n"^(cxt_list2string tail)
|
||||
| cxt_list2string ((Inv(p,s,t))::tail) =
|
||||
"inv: "^(Ocl2String.ocl2string false t)^"\n"^(cxt_list2string tail)
|
||||
| cxt_list2string ((Attr(p,ty,a,t))::tail) =
|
||||
"attr_or_assoc "^(Ocl2String.ocl2string false t)^"\n"^(cxt_list2string tail)
|
||||
| cxt_list2string ((Cond(p,s,l,ty,c,so,t))::tail) =
|
||||
"condition: "^(Ocl2String.ocl2string false t)^"\n"^(cxt_list2string tail)
|
||||
| cxt_list2string ((Guard(p,so,t))::tail) =
|
||||
"guard: "^(Ocl2String.ocl2string false t)^"\n"^(cxt_list2string tail)
|
||||
*)
|
||||
|
||||
fun string_of_arglist [] = ""
|
||||
| string_of_arglist [(n,t)] = n^":"^(Rep_OclType.string_of_OclType t)
|
||||
| string_of_arglist (x::xs) = (string_of_arglist [x])^", "^(string_of_arglist xs)
|
||||
|
||||
fun cxt2string (Empty_context(s,t)) = s^"\n"
|
||||
^" empty: "^(Ocl2String.ocl2string false t)^"\n"
|
||||
|
||||
| cxt2string (Inv(p,NONE,t)) = (Rep_Core.string_of_path p)^"\n"
|
||||
^" inv: "^(Ocl2String.ocl2string false t)^"\n"
|
||||
| cxt2string (Inv(p,SOME cn,t)) = (Rep_Core.string_of_path p)^"\n"
|
||||
^" inv "^cn^": "^(Ocl2String.ocl2string false t)^"\n"
|
||||
|
||||
| cxt2string (Attr(p,ty,derive,t)) = (Rep_Core.string_of_path p)^"\n"
|
||||
^" derive: "^(Ocl2String.ocl2string false t)^"\n"
|
||||
| cxt2string (Attr(p,ty,init,t)) = (Rep_Core.string_of_path p)^"\n"
|
||||
^" init: "^(Ocl2String.ocl2string false t)^"\n"
|
||||
| cxt2string (Attr(p,ty,def,t)) = (Rep_Core.string_of_path p)^"\n"
|
||||
^" def: "^(Ocl2String.ocl2string false t)^"\n"
|
||||
|
||||
| cxt2string (Cond(p,s,l,ty,pre,NONE,t)) = (Rep_Core.string_of_path (tl p))^"::"^s^"("^(string_of_arglist l)^"):"^(Rep_OclType.string_of_OclType ty)^"\n"
|
||||
^" pre: "^(Ocl2String.ocl2string false t)^"\n"
|
||||
| cxt2string (Cond(p,s,l,ty,pre,SOME cn,t)) = (Rep_Core.string_of_path (tl p))^"::"^s^"("^(string_of_arglist l)^"):"^(Rep_OclType.string_of_OclType ty)^"\n"
|
||||
^" pre "^cn^": "^(Ocl2String.ocl2string false t)^"\n"
|
||||
| cxt2string (Cond(p,s,l,ty,post,NONE,t)) = (Rep_Core.string_of_path (tl p))^"::"^s^"("^(string_of_arglist l)^"):"^(Rep_OclType.string_of_OclType ty)^"\n"
|
||||
^" post: "^(Ocl2String.ocl2string false t)^"\n"
|
||||
| cxt2string (Cond(p,s,l,ty,post,SOME cn,t)) = (Rep_Core.string_of_path (tl p))^"::"^s^"("^(string_of_arglist l)^"):"^(Rep_OclType.string_of_OclType ty)^"\n"
|
||||
^" post "^cn^": "^(Ocl2String.ocl2string false t)^"\n"
|
||||
| cxt2string (Cond(p,s,l,ty,body,NONE,t)) = (Rep_Core.string_of_path (tl p))^"::"^s^"("^(string_of_arglist l)^"):"^(Rep_OclType.string_of_OclType ty)^"\n"
|
||||
^" body: "^(Ocl2String.ocl2string false t)^"\n"
|
||||
| cxt2string (Cond(p,s,l,ty,body,SOME cn,t)) = (Rep_Core.string_of_path (tl p))^"::"^s^"("^(string_of_arglist l)^"):"^(Rep_OclType.string_of_OclType ty)^"\n"
|
||||
^" body "^cn^": "^(Ocl2String.ocl2string false t)^"\n"
|
||||
|
||||
| cxt2string (Guard(p,NONE,t)) = (Rep_Core.string_of_path p)^"\n"
|
||||
^" guard: "^(Ocl2String.ocl2string false t)^"\n"
|
||||
| cxt2string (Guard(p,SOME cn,t)) = (Rep_Core.string_of_path p)^"\n"
|
||||
^" guard "^cn^": "^(Ocl2String.ocl2string false t)^"\n"
|
||||
|
||||
fun cxt_list2string ctxs = String.concat (map cxt2string ctxs)
|
||||
|
||||
fun rename_classifier path (Class{name=name,parent=parent,attributes=attributes,operations=operations,associations=associations,invariant=invariant,stereotypes=stereotypes,interfaces=interfaces,thyname=thyname,visibility=visibility,activity_graphs=activity_graphs}) =
|
||||
let
|
||||
|
|
|
@ -49,6 +49,7 @@ sig
|
|||
exception TC_TypeCheckerResolveIfError of Rep_OclTerm.OclTerm * string
|
||||
exception TC_NotYetSupportedError of string
|
||||
exception TC_WrongContextChecked of Context.context
|
||||
exception TC_ContextNotDefined of Context.context
|
||||
exception TC_RootError of string
|
||||
(* exception TC_AsSetError of (Rep_OclTerm.OclTerm * string list * int *
|
||||
* (Rep_OclTerm.OclTerm * Rep_OclType.OclType) list * Rep_Core.transform_model)
|
||||
|
@ -85,6 +86,7 @@ open Ocl2String
|
|||
type operation = Rep_Core.operation
|
||||
type attribute = Rep_Core.attribute
|
||||
|
||||
exception TC_ContextNotDefined of Context.context
|
||||
exception TC_RootError of string
|
||||
exception TC_wrongCollectionLiteral of Rep_OclTerm.OclTerm * string
|
||||
exception TC_CollectionRangeError of Rep_OclTerm.CollectionPart * string
|
||||
|
@ -711,6 +713,7 @@ fun check_context (Cond (path,op_name,op_sign,result_type,cond,pre_name,expr)) (
|
|||
val _ = Logger.debug3 ("pre/post/body : " ^ Ocl2String.ocl2string false expr ^ "\n")
|
||||
val classifier = class_of_type (Classifier (path)) model
|
||||
val oper = get_operation op_name classifier model
|
||||
handle Option => raise TC_ContextNotDefined (Cond (path,op_name,op_sign,result_type,cond,pre_name,expr))
|
||||
val check1 = (op_sign = (#arguments oper))
|
||||
val check2 = (result_type = (#result oper))
|
||||
val _ = Logger.debug3 ("check1 = " ^ Bool.toString check1 ^ ", check2 = " ^ Bool.toString check2 ^ "\n")
|
||||
|
@ -722,7 +725,6 @@ fun check_context (Cond (path,op_name,op_sign,result_type,cond,pre_name,expr)) (
|
|||
else
|
||||
(* NONE *)
|
||||
raise TC_WrongContextChecked (Cond (path,op_name,op_sign,result_type,cond,pre_name,expr))
|
||||
|
||||
val _ = Logger.debug2 ("TypeChecker.check_context Cond(...)\n\n\n")
|
||||
in
|
||||
res
|
||||
|
@ -794,10 +796,14 @@ fun check_context_list [] model = []
|
|||
| GetClassifierError mes => Logger.error ("GetClassifierError: "^mes^"\n"
|
||||
^" in context: "^(cxt_list2string [h]))
|
||||
| TC_NoSuchOperationError mes => Logger.error ("NoSuchOperationError: "^mes^"\n"
|
||||
^" in context: "^(cxt_list2string [h]))
|
||||
^" in context: "^(cxt_list2string [h]))
|
||||
| TC_ContextNotDefined h => Logger.error ("Context not defined in UML model:\n"
|
||||
^(cxt_list2string [h]))
|
||||
| Option => Logger.error ("hadling otpin")
|
||||
)::(check_context_list context_list_tail model))
|
||||
|
||||
handle TC_WrongContextChecked h => Logger.error ("Unkown Error in context: "
|
||||
^(cxt_list2string [h]))
|
||||
| Option => Logger.error ("hadling option outer")
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue