mirror of
https://github.com/elastic/logstash.git
synced 2025-04-24 14:47:19 -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::FlushEvent; end
|
||||
|
||||
# Custom exceptions
|
||||
class InvalidOperationException < StandardError; end
|
||||
|
||||
module LogStash
|
||||
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
|
||||
def remove(fieldref)
|
||||
if fieldref == TIMESTAMP || fieldref == "[#{TIMESTAMP}]"
|
||||
raise TypeError, "The field '@timestamp' must not be removed"
|
||||
raise InvalidOperationException, "The field '@timestamp' must not be removed"
|
||||
end
|
||||
@accessors.del(fieldref)
|
||||
end
|
||||
|
|
|
@ -336,7 +336,7 @@ describe LogStash::Event do
|
|||
|
||||
context "remove" 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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue