Skip to content
This repository was archived by the owner on Jan 27, 2023. It is now read-only.

Commit bae8aed

Browse files
committed
update error message to be an invalid schema error instead of internal error
1 parent d077112 commit bae8aed

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

lib/cipherstash/analysis/text_processor.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,15 @@ def build_token_filters(array)
4747

4848
when "ngram"
4949
if obj["tokenLength"]
50-
raise CipherStash::Client::Error::InternalError, "'tokenLength' is deprecated. Use 'minLength' and 'maxLength' for the ngram filter."
50+
raise CipherStash::Client::Error::InvalidSchemaError, "'tokenLength' is deprecated. Use 'minLength' and 'maxLength' for the ngram filter."
5151
end
5252

5353
unless obj["minLength"].instance_of?(Integer) && obj["maxLength"].instance_of?(Integer)
54-
raise CipherStash::Client::Error::InternalError, "The values provided to the min and max length must be of type Integer."
54+
raise CipherStash::Client::Error::InvalidSchemaError, "The values provided to the min and max length must be of type Integer."
5555
end
5656

5757
unless obj["maxLength"] >= obj["minLength"]
58-
raise CipherStash::Client::Error::InternalError, "The ngram filter min length must be less than or equal to the max length"
58+
raise CipherStash::Client::Error::InvalidSchemaError, "The ngram filter min length must be less than or equal to the max length"
5959
end
6060

6161
TokenFilters::NGram.new(obj)

spec/cipherstash/analysis/text_processor_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
],
2929
"tokenizer" => { "kind" => "standard" }
3030
})
31-
}.to raise_error(CipherStash::Client::Error::InternalError, "The values provided to the min and max length must be of type Integer.")
31+
}.to raise_error(CipherStash::Client::Error::InvalidSchemaError, "The values provided to the min and max length must be of type Integer.")
3232
end
3333
end
3434

@@ -41,7 +41,7 @@
4141
],
4242
"tokenizer" => { "kind" => "standard" }
4343
})
44-
}.to raise_error(CipherStash::Client::Error::InternalError, "The ngram filter min length must be less than or equal to the max length")
44+
}.to raise_error(CipherStash::Client::Error::InvalidSchemaError, "The ngram filter min length must be less than or equal to the max length")
4545
end
4646

4747
it "raises an error if tokenLength is provided" do
@@ -53,7 +53,7 @@
5353
],
5454
"tokenizer" => { "kind" => "standard" }
5555
})
56-
}.to raise_error(CipherStash::Client::Error::InternalError, "'tokenLength' is deprecated. Use 'minLength' and 'maxLength' for the ngram filter.")
56+
}.to raise_error(CipherStash::Client::Error::InvalidSchemaError, "'tokenLength' is deprecated. Use 'minLength' and 'maxLength' for the ngram filter.")
5757
end
5858

5959
it "splits text into ngrams using min length of 3 and max length of 8" do

0 commit comments

Comments
 (0)