throwCheckedIfNull method
데이터가 null일 경우 CheckedException을 발생시키고, 아닐 경우 Non-nullable 값을 반환합니다.
예외 발생 시 어떤 타입(T)이 null이었는지 로그에 명시합니다.
주로 API 필수 응답값이 누락되는 등 비즈니스 로직상 필수 데이터가 없을 때 사용합니다.
Throws a CheckedException if the value is null, otherwise returns the non-nullable value.
Mentions the specific type T in the error value for better debugging.
Implementation
T throwCheckedIfNull({
required String prefix,
({String english, String locale}) message = (english: '', locale: ''),
}) {
if (this == null) {
throw GenericCheckedException(value: this, prefix: prefix, message: message);
}
return this as T;
}