2020-08-13 23:39:26 +02:00
|
|
|
import objecttype
|
2020-08-23 12:10:08 +02:00
|
|
|
import stringtype
|
2020-08-23 23:48:38 +02:00
|
|
|
import strformat
|
2020-08-10 18:39:53 +02:00
|
|
|
|
|
|
|
|
2020-08-23 12:10:08 +02:00
|
|
|
type JAPLException* = ref object of Obj
|
2020-08-25 10:24:50 +02:00
|
|
|
errName*: ptr String
|
|
|
|
message*: ptr String
|
2020-08-10 18:39:53 +02:00
|
|
|
|
2020-08-13 23:39:26 +02:00
|
|
|
|
2020-08-23 23:48:38 +02:00
|
|
|
proc stringify*(self: JAPLException): string =
|
|
|
|
return &"{self.errName.str}: {self.message.str}"
|
|
|
|
|
|
|
|
proc newTypeError*(message: string): JAPLException =
|
2020-08-23 12:10:08 +02:00
|
|
|
result = JAPLException(kind: ObjectTypes.EXCEPTION, errName: newString("TypeError"), message: newString(message))
|
2020-08-14 10:02:13 +02:00
|
|
|
|
|
|
|
|
2020-08-23 23:48:38 +02:00
|
|
|
proc newIndexError*(message: string): JAPLException =
|
2020-08-23 12:10:08 +02:00
|
|
|
result = JAPLException(kind: ObjectTypes.EXCEPTION, errName: newString("IndexError"), message: newString(message))
|
2020-08-14 10:02:13 +02:00
|
|
|
|
2020-08-15 11:27:04 +02:00
|
|
|
|
2020-08-23 23:48:38 +02:00
|
|
|
proc newReferenceError*(message: string): JAPLException =
|
2020-08-23 12:10:08 +02:00
|
|
|
result = JAPLException(kind: ObjectTypes.EXCEPTION, errName: newString("ReferenceError"), message: newString(message))
|
2020-08-15 11:27:04 +02:00
|
|
|
|
2020-08-19 18:15:48 +02:00
|
|
|
|
2020-08-23 23:48:38 +02:00
|
|
|
proc newInterruptedError*(message: string): JAPLException =
|
2020-08-23 12:10:08 +02:00
|
|
|
result = JAPLException(kind: ObjectTypes.EXCEPTION, errName: newString("InterruptedError"), message: newString(message))
|
|
|
|
|
2020-08-19 18:15:48 +02:00
|
|
|
|