cOrcS /src/orc/lib/util/Error.scala

Language Scala Lines 40
MD5 Hash bff69ffaf522c2433a90b3fd7c368016
Repository https://github.com/laurenyew/cOrcS.git View Raw File
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
//
// Error.scala -- Scala object Error
// Project OrcScala
//
// $Id: Error.scala 2933 2011-12-15 16:26:02Z jthywissen $
//
// Created by jthywiss on Dec 16, 2010.
//
// Copyright (c) 2011 The University of Texas at Austin. All rights reserved.
//
// Use and redistribution of this file is governed by the license terms in
// the LICENSE file found in the project's top-level directory and also found at
// URL: http://orc.csres.utexas.edu/license.shtml .
//
package orc.lib.util

import orc.values.sites.TotalSite
import orc.values.sites.TotalSite1
import orc.values.sites.TypedSite
import orc.error.runtime.ArgumentTypeMismatchException
import orc.error.runtime.ProgramSignalledError
import orc.types.Bot
import orc.types.SimpleFunctionType
import orc.types.StringType

/** The Error site throws an Orc runtime exception with a program supplied message.
  *
  * @author jthywiss
  */
object Error extends TotalSite with TotalSite1 with TypedSite {
  def eval(x: AnyRef) = {
    x match {
      case s: String => throw new ProgramSignalledError(s)
      case _ => throw new ArgumentTypeMismatchException(0, "String", if (x != null) Option(x.getClass.getCanonicalName).getOrElse(x.getClass.getName) else "null")
    }
  }

  def orcType = SimpleFunctionType(StringType, Bot)
}
Back to Top