rage-rb / rage

Fast web framework compatible with Rails.
MIT License
780 stars 12 forks source link

Unknown Environment Error Handling #95

Closed cuneyter closed 2 months ago

cuneyter commented 2 months ago

Unknown Environment Error Handling

Description

This PR addresses the issue of Rage failing with a "cannot load such file" exception when an invalid environment name is provided. Instead of the generic error, this PR introduces a custom error with a meaningful message indicating that the specified environment could not be found.

Issue Addressed

Changes Made

  1. Error Handling in setup.rb:

    • Wrapped the require_relative call in a begin...rescue block.
    • Caught the LoadError and raised a LoadError with a custom message indicating the invalid environment name.
  2. RSpec Test:

    • Added tests to check if the custom error is raised correctly when an invalid environment name is provided.

Screenshots

Documentation

No documentation changes are necessary as this update enhances error handling for existing functionality.