[Dart] CustomException
페이지 정보
작성자 sbLAB 댓글 0건 조회 2,047회 작성일 23-03-26 10:23본문
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");
}
}
- 이전글Flutter FCM (Firebase Cloud Messaging) 23.04.23
- 다음글[Flutter] How to remove scroll glow? 23.03.19
댓글목록
등록된 댓글이 없습니다.