Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR DART

dart custom exception

class CustomException implements Exception {
  String errorMessage() {
    return ("Invalid Amount");
  }
}

void AmountException(int amount) {
  if (amount <= 0) {
    throw new CustomException();
  }
}

void main() {
  try {
    AmountException(0);
  } catch (e) {
    print(errorMessage());
  }
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #dart #custom #exception
ADD COMMENT
Topic
Name
8+3 =