diff --git a/lib/src/configuration.dart b/lib/src/configuration.dart index 4bd299a..d3aa78f 100644 --- a/lib/src/configuration.dart +++ b/lib/src/configuration.dart @@ -86,14 +86,8 @@ class Configuration { Log.startingTask(taskName); await _findAndSetCliPath(); - try { - final reader = ConfigReader(); - loadConfig(reader); - } catch (e) { - // Will catch an exception if no proper config could be found e.g sentry.properties or pubspec.yaml - Log.error(e.toString()); - return; - } + final reader = ConfigReader(); + loadConfig(reader); Log.taskCompleted(taskName); } diff --git a/lib/src/utils/config-reader/config_reader.dart b/lib/src/utils/config-reader/config_reader.dart index e9ccf60..18611a3 100644 --- a/lib/src/utils/config-reader/config_reader.dart +++ b/lib/src/utils/config-reader/config_reader.dart @@ -4,6 +4,7 @@ import 'package:file/file.dart'; import '../injector.dart'; import '../log.dart'; +import 'no_op_config_reader.dart'; import 'properties_config_reader.dart'; import 'yaml_config_reader.dart'; @@ -35,8 +36,8 @@ abstract class ConfigReader { Properties.fromString(propertiesFile.readAsStringSync()); return PropertiesConfigReader(properties); } - throw Exception( - 'no config found, please use sentry.properties or pubspec.yaml.'); + Log.error('no config found, please use sentry.properties or pubspec.yaml.'); + return NoOpConfigReader(); } static dynamic getPubspec() { diff --git a/lib/src/utils/config-reader/no_op_config_reader.dart b/lib/src/utils/config-reader/no_op_config_reader.dart new file mode 100644 index 0000000..e792e28 --- /dev/null +++ b/lib/src/utils/config-reader/no_op_config_reader.dart @@ -0,0 +1,20 @@ +import 'config_reader.dart'; + +class NoOpConfigReader implements ConfigReader { + NoOpConfigReader(); + + @override + bool? getBool(String key, {String? deprecatedKey}) { + return null; + } + + @override + String? getString(String key, {String? deprecatedKey}) { + return null; + } + + @override + bool contains(String key) { + return false; + } +}