exception_01.bmx 748 B

123456789101112131415161718192021222324252627282930313233
  1. SuperStrict
  2. Framework Brl.Standardio
  3. Type TMyException Extends TBlitzException
  4. Field message:String
  5. Method ToString:String()
  6. If message = Null then Return GetDefaultMessage()
  7. Return message
  8. End Method
  9. Method GetDefaultMessage:String()
  10. Return "Undefined TMyException!"
  11. End Method
  12. End Type
  13. print "start TRY"
  14. Try
  15. local tmpObj:TMyException = null
  16. if not tmpObj
  17. local myException:TMyException = New TMyException
  18. myException.message = "assignment to null is not allowed"
  19. Throw myException
  20. endif
  21. tmpObj.message = "123" 'fails
  22. print "assignment possible while not allowed"
  23. Catch ex:Object
  24. if not TBlitzException(ex) then print "unknown exception:"
  25. print ex.ToString()
  26. End Try
  27. print "end TRY"