[Dart] CustomException > Flutter/Dart/Node

본문 바로가기
사이트 내 전체검색

Flutter/Dart/Node

[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");
    }
  }

  


https://youtu.be/tI252cev-Ec



댓글목록

등록된 댓글이 없습니다.

회원로그인

접속자집계

오늘
426
어제
342
최대
1,279
전체
218,661

그누보드5
Copyright © sebom.com All rights reserved.