mirror of
https://github.com/meineerde/rackstash.git
synced 2026-02-11 13:05:19 +00:00
Raise ArgumentError when trying to resolve an unknown adapter URI
If we were to fall through, undefined schemes would always end up as a file adapter. This is generally undesired since it hides the fact that we have not found a suitable adapter. Most of the time, this will be a configuration error which should be reported early. If a user still wants to create a file adapter with a filename that looks like a URI, they can create a Rackstash::Adapter::File object manually.
This commit is contained in:
parent
bdeb0534c9
commit
e8bf2c31bd
@ -110,7 +110,9 @@ module Rackstash
|
|||||||
scheme = uri.scheme || uri.opaque
|
scheme = uri.scheme || uri.opaque
|
||||||
|
|
||||||
return unless scheme
|
return unless scheme
|
||||||
adapter_class = adapter_schemes.fetch(scheme.to_s.downcase) { return }
|
adapter_class = adapter_schemes.fetch(scheme.to_s.downcase) {
|
||||||
|
raise ArgumentError, "No log adapter found for URI #{uri}"
|
||||||
|
}
|
||||||
|
|
||||||
if adapter_class.respond_to?(:from_uri)
|
if adapter_class.respond_to?(:from_uri)
|
||||||
adapter_class.from_uri(uri)
|
adapter_class.from_uri(uri)
|
||||||
|
|||||||
@ -261,8 +261,9 @@ describe Rackstash::Adapter do
|
|||||||
unknown_uri = 'unknown://example.com'
|
unknown_uri = 'unknown://example.com'
|
||||||
|
|
||||||
expect(adapter).to_not receive(:from_uri)
|
expect(adapter).to_not receive(:from_uri)
|
||||||
expect(adapter).to receive(:new).with(unknown_uri).and_call_original
|
expect(adapter).not_to receive(:new)
|
||||||
expect(described_class[unknown_uri]).to be_an Rackstash::Adapter::BaseAdapter
|
expect { described_class[unknown_uri] }
|
||||||
|
.to raise_error ArgumentError, "No log adapter found for URI unknown://example.com"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user