PageRenderTime 44ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

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

https://github.com/laurenyew/cOrcS
Scala | 39 lines | 18 code | 3 blank | 18 comment | 3 complexity | bff69ffaf522c2433a90b3fd7c368016 MD5 | raw file
Possible License(s): BSD-3-Clause
  1. //
  2. // Error.scala -- Scala object Error
  3. // Project OrcScala
  4. //
  5. // $Id: Error.scala 2933 2011-12-15 16:26:02Z jthywissen $
  6. //
  7. // Created by jthywiss on Dec 16, 2010.
  8. //
  9. // Copyright (c) 2011 The University of Texas at Austin. All rights reserved.
  10. //
  11. // Use and redistribution of this file is governed by the license terms in
  12. // the LICENSE file found in the project's top-level directory and also found at
  13. // URL: http://orc.csres.utexas.edu/license.shtml .
  14. //
  15. package orc.lib.util
  16. import orc.values.sites.TotalSite
  17. import orc.values.sites.TotalSite1
  18. import orc.values.sites.TypedSite
  19. import orc.error.runtime.ArgumentTypeMismatchException
  20. import orc.error.runtime.ProgramSignalledError
  21. import orc.types.Bot
  22. import orc.types.SimpleFunctionType
  23. import orc.types.StringType
  24. /** The Error site throws an Orc runtime exception with a program supplied message.
  25. *
  26. * @author jthywiss
  27. */
  28. object Error extends TotalSite with TotalSite1 with TypedSite {
  29. def eval(x: AnyRef) = {
  30. x match {
  31. case s: String => throw new ProgramSignalledError(s)
  32. case _ => throw new ArgumentTypeMismatchException(0, "String", if (x != null) Option(x.getClass.getCanonicalName).getOrElse(x.getClass.getName) else "null")
  33. }
  34. }
  35. def orcType = SimpleFunctionType(StringType, Bot)
  36. }