Skip to content

Commit 4b0fb9e

Browse files
committed
Config::from_env never returns an error.
We don't need to return Result because the function either panics or returns the Ok value. Signed-off-by: David Calavera <david.calavera@gmail.com>
1 parent 2a2ae8b commit 4b0fb9e

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

lambda-runtime/src/lib.rs

+5-6
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ type RefConfig = Arc<Config>;
6464

6565
impl Config {
6666
/// Attempts to read configuration from environment variables.
67-
pub fn from_env() -> Result<Self, Error> {
68-
let conf = Config {
67+
pub fn from_env() -> Self {
68+
Config {
6969
function_name: env::var("AWS_LAMBDA_FUNCTION_NAME").expect("Missing AWS_LAMBDA_FUNCTION_NAME env var"),
7070
memory: env::var("AWS_LAMBDA_FUNCTION_MEMORY_SIZE")
7171
.expect("Missing AWS_LAMBDA_FUNCTION_MEMORY_SIZE env var")
@@ -74,8 +74,7 @@ impl Config {
7474
version: env::var("AWS_LAMBDA_FUNCTION_VERSION").expect("Missing AWS_LAMBDA_FUNCTION_VERSION env var"),
7575
log_stream: env::var("AWS_LAMBDA_LOG_STREAM_NAME").unwrap_or_default(),
7676
log_group: env::var("AWS_LAMBDA_LOG_GROUP_NAME").unwrap_or_default(),
77-
};
78-
Ok(conf)
77+
}
7978
}
8079
}
8180

@@ -254,7 +253,7 @@ where
254253
E: Into<Error> + Send + Debug,
255254
{
256255
trace!("Loading config from env");
257-
let config = Config::from_env()?;
256+
let config = Config::from_env();
258257
let client = Client::builder().build().expect("Unable to create a runtime client");
259258
let runtime = Runtime {
260259
client,
@@ -527,7 +526,7 @@ mod endpoint_tests {
527526
if env::var("AWS_LAMBDA_LOG_GROUP_NAME").is_err() {
528527
env::set_var("AWS_LAMBDA_LOG_GROUP_NAME", "test_log");
529528
}
530-
let config = Config::from_env().expect("Failed to read env vars");
529+
let config = Config::from_env();
531530

532531
let runtime = Runtime {
533532
client,

0 commit comments

Comments
 (0)