Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR DART

throw error in dart

class CustomException implements Exception {
  String cause;
  CustomException(this.cause);
}

void main() {
  try {
    throwException();
  } on CustomException {
    print("custom exception has been obtained");
  }
}

throwException() {
  throw new CustomException('This is my first custom exception');
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #throw #error #dart
ADD COMMENT
Topic
Name
8+3 =