Answers for "create Exception ddart"

1

dart custom exception

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

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

throwException() {
  throw new CustomException('This is my first custom exception');
}
Posted by: Guest on July-27-2020

Code answers related to "create Exception ddart"

Browse Popular Code Answers by Language