[Dart] CustomException > Node/Flutter/Dart

본문 바로가기

사이트 내 전체검색

Node/Flutter/Dart

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

  


https://youtu.be/tI252cev-Ec



댓글목록

등록된 댓글이 없습니다.

Copyright © 소유하신 도메인. All rights reserved.
PC 버전으로 보기