Skip to content

Commit 21571ff

Browse files
committed
fix(config): replace FormatException with StateError for environment variable check
- Replace FormatException with StateError for more appropriate error handling - Remove unnecessary empty line at the beginning of the file - Adjust spacing in the thrown error message for better readability
1 parent b6b23a0 commit 21571ff

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

lib/app/config/app_config.dart

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
import 'package:flutter_news_app_web_dashboard_full_source_code/app/config/app_environment.dart';
32

43
/// A class to hold all environment-specific configurations.
@@ -23,7 +22,7 @@ class AppConfig {
2322
const baseUrl = String.fromEnvironment('BASE_URL');
2423
if (baseUrl.isEmpty) {
2524
// This check is crucial for production builds.
26-
throw const FormatException(
25+
throw StateError(
2726
'FATAL: The BASE_URL compile-time variable was not provided for this '
2827
'production build. Ensure the build command includes '
2928
'--dart-define=BASE_URL=https://your.api.com',
@@ -49,4 +48,4 @@ class AppConfig {
4948

5049
final AppEnvironment environment;
5150
final String baseUrl;
52-
}
51+
}

0 commit comments

Comments
 (0)