@@ -2,11 +2,12 @@ import * as ast from "./ast";
22import { Message } from "./message" ;
33import { Value , StringValue } from "./value" ;
44import { Result , Success , Failure } from "./result" ;
5+ import { ScopeError , ErrorKind } from "./error" ;
56
67export class Scope {
78 private readonly messages : Map < string , Message > ;
89 private readonly variables : Map < string , Value > ;
9- public errors : Array < string > ;
10+ public errors : Array < ScopeError > ;
1011
1112 constructor ( messages : Map < string , Message > , variables : Map < string , Value > ) {
1213 this . messages = messages ;
@@ -32,7 +33,7 @@ export class Scope {
3233 if ( value !== undefined ) {
3334 return new Success ( value ) ;
3435 } else {
35- this . errors . push ( `Unknown variable: $ ${ node . id . name } .` ) ;
36+ this . errors . push ( new ScopeError ( ErrorKind . UnknownVariable , node . id . name ) ) ;
3637 return new Failure ( new StringValue ( `$${ node . id . name } ` ) ) ;
3738 }
3839 }
@@ -42,7 +43,7 @@ export class Scope {
4243 if ( message !== undefined ) {
4344 return message . resolveValue ( this ) ;
4445 } else {
45- this . errors . push ( `Unknown message: ${ node . id . name } .` ) ;
46+ this . errors . push ( new ScopeError ( ErrorKind . UnknownMessage , node . id . name ) ) ;
4647 return new Failure ( new StringValue ( `${ node . id . name } ` ) ) ;
4748 }
4849 }
0 commit comments