mirror of
https://github.com/elastic/logstash.git
synced 2025-04-25 07:07:54 -04:00
parent
e023bd4bc6
commit
6bf6e38f59
2 changed files with 5 additions and 2 deletions
|
@ -16,6 +16,9 @@ require "logstash/string_interpolation"
|
||||||
class LogStash::ShutdownEvent; end
|
class LogStash::ShutdownEvent; end
|
||||||
class LogStash::FlushEvent; end
|
class LogStash::FlushEvent; end
|
||||||
|
|
||||||
|
# Custom exceptions
|
||||||
|
class InvalidOperationException < StandardError; end
|
||||||
|
|
||||||
module LogStash
|
module LogStash
|
||||||
FLUSH = LogStash::FlushEvent.new
|
FLUSH = LogStash::FlushEvent.new
|
||||||
|
|
||||||
|
@ -180,7 +183,7 @@ class LogStash::Event
|
||||||
# Remove a field or field reference. Returns the value of that field when deleted
|
# Remove a field or field reference. Returns the value of that field when deleted
|
||||||
def remove(fieldref)
|
def remove(fieldref)
|
||||||
if fieldref == TIMESTAMP || fieldref == "[#{TIMESTAMP}]"
|
if fieldref == TIMESTAMP || fieldref == "[#{TIMESTAMP}]"
|
||||||
raise TypeError, "The field '@timestamp' must not be removed"
|
raise InvalidOperationException, "The field '@timestamp' must not be removed"
|
||||||
end
|
end
|
||||||
@accessors.del(fieldref)
|
@accessors.del(fieldref)
|
||||||
end
|
end
|
||||||
|
|
|
@ -336,7 +336,7 @@ describe LogStash::Event do
|
||||||
|
|
||||||
context "remove" do
|
context "remove" do
|
||||||
it "should raise an exception if you attempt to remove @timestamp" do
|
it "should raise an exception if you attempt to remove @timestamp" do
|
||||||
expect{subject.remove("@timestamp")}.to raise_error(TypeError)
|
expect{subject.remove("@timestamp")}.to raise_error(InvalidOperationException)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue