[Dart] CustomException
작성일 23-03-26 10:23
페이지 정보
작성자sbLAB 조회 2,268회 댓글 0건본문
CustomException
void main() {
try {
throwException(-200);
} on CustomException catch (e) {
print(e.errorMessage());
}
}
class CustomException implements Exception {
String cause;
CustomException(this.cause);
String errorMessage() {
return cause;
}
}
void throwException(int amount) {
if (amount < 0) {
throw CustomException("The amount less than zero not acceptable");
}
}
댓글목록
등록된 댓글이 없습니다.