Skip to content

Commit

Permalink
Object.m: Check for errors in GetObjectField
Browse files Browse the repository at this point in the history
  • Loading branch information
ianhinder committed Mar 18, 2014
1 parent 21ddd73 commit b2679d0
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion Tools/CodeGen/Object.m
Expand Up @@ -51,7 +51,10 @@

DefFn[
GetObjectField[obj_, field_String] :=
Cases[obj, (field -> value_) :> value][[1]]];
Replace[Cases[obj, (field -> value_) :> value], {
{} :> ThrowError["Field "<>field<>" not found in "<>ToString[Head[obj]]],
{val_} :> val,
_ :> ThrowError["Error while reading "<>field<>" from "<>ToString[Head[obj]]]}]];

(* High level functions *)

Expand Down

0 comments on commit b2679d0

Please sign in to comment.