japl/nim/types/exceptions.nim

26 lines
840 B
Nim
Raw Normal View History

import objecttype
import stringtype
2020-08-10 18:39:53 +02:00
type JAPLException* = ref object of Obj
errName*: String
message*: String
2020-08-10 18:39:53 +02:00
func newTypeError*(message: string): JAPLException =
result = JAPLException(kind: ObjectTypes.EXCEPTION, errName: newString("TypeError"), message: newString(message))
func newIndexError*(message: string): JAPLException =
result = JAPLException(kind: ObjectTypes.EXCEPTION, errName: newString("IndexError"), message: newString(message))
func newReferenceError*(message: string): JAPLException =
result = JAPLException(kind: ObjectTypes.EXCEPTION, errName: newString("ReferenceError"), message: newString(message))
func newInterruptedError*(message: string): JAPLException =
result = JAPLException(kind: ObjectTypes.EXCEPTION, errName: newString("InterruptedError"), message: newString(message))