BazaRb raises RuntimeError for everything — no custom error hierarchy for callers
Severity: MEDIUM (Design/API)
Location
lib/baza-rb.rb — everywhere:
raise 'Invalid parameter' # RuntimeError
raise(BadCompression, '...') # BadCompression < RuntimeError
raise(Error, '...') # Error < RuntimeError (rarely used)
Problem
Callers cannot distinguish error types:
begin
baza.push(...)
rescue => e
# Is this a validation error? Network error? Server error?
# Must parse e.message, which may change
end
Recommended fix
Introduce an error hierarchy:
module BazaRb
class Error < StandardError; end
class ValidationError < Error; end
class InvalidName < ValidationError; end
class InvalidAmount < ValidationError; end
class ApiError < Error; end
class BadCompression < Error; end
class Unauthorized < ApiError; end
class NotFound < ApiError; end
class TooManyRequests < ApiError; end
class RetryExhausted < Error; end
end
This allows callers to catch specific error groups without parsing messages.
BazaRb raises RuntimeError for everything — no custom error hierarchy for callers
Severity: MEDIUM (Design/API)
Location
lib/baza-rb.rb— everywhere:Problem
Callers cannot distinguish error types:
Recommended fix
Introduce an error hierarchy:
This allows callers to catch specific error groups without parsing messages.