Apex カスタム例外クラスの作成サンプル

環境
Salesforce

操作方法
1.カスタム例外クラスの作成
書式
public class 例外クラス名 extends Exception {}

使用例
public class TestException extends Exception {}

2.カスタム例外の発生方法
1).引数なしの例外を投げる
throw new TestException();

2).Exception型の引数を指定する

throw new TestException(e);

3).エラーメッセージとException型の引数を指定

throw new TestException('エラーメッセージ', e);

4).エラーメッセージを指定

throw new TestException('エラーメッセージ');

 

Apex

Posted by arkgame