Skip to content

Commit

Permalink
add StringIndexError documentation (#26747)
Browse files Browse the repository at this point in the history
  • Loading branch information
bkamins authored and JeffBezanson committed Apr 12, 2018
1 parent a3bf547 commit 52f27a7
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 3 deletions.
4 changes: 2 additions & 2 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ This section lists changes that do not have deprecation warnings.
* `countlines` now always counts the last non-empty line even if it does not
end with EOL, matching the behavior of `eachline` and `readlines` ([#25845]).

* `getindex(s::String, r::UnitRange{Int})` now throws `UnicodeError` if `last(r)`
* `getindex(s::String, r::UnitRange{Int})` now throws `StringIndexError` if `last(r)`
is not a valid index into `s` ([#22572]).

* `ntuple(f, n::Integer)` throws `ArgumentError` if `n` is negative.
Expand Down Expand Up @@ -1446,4 +1446,4 @@ Command-line option changes
[#26436]: https://github.com/JuliaLang/julia/issues/26436
[#26442]: https://github.com/JuliaLang/julia/issues/26442
[#26600]: https://github.com/JuliaLang/julia/issues/26600
[#26670]: https://github.com/JuliaLang/julia/issues/26670
[#26670]: https://github.com/JuliaLang/julia/issues/26670
5 changes: 5 additions & 0 deletions base/strings/string.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# This file is a part of Julia. License is MIT: https://julialang.org/license

"""
StringIndexError(str, i)
An error occurred when trying to access `str` at index `i` that is not valid.
"""
struct StringIndexError <: Exception
string::AbstractString
index::Integer
Expand Down
1 change: 1 addition & 0 deletions doc/src/base/base.md
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@ Core.TypeError
Core.UndefKeywordError
Core.UndefRefError
Core.UndefVarError
Base.StringIndexError
Base.InitError
Base.retry
Base.ExponentialBackOff
Expand Down
2 changes: 1 addition & 1 deletion doc/src/manual/control-flow.md
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ below all interrupt the normal flow of control.
| [`TypeError`](@ref) |
| [`UndefRefError`](@ref) |
| [`UndefVarError`](@ref) |
| `UnicodeError` |
| [`StringIndexError`](@ref) |

For example, the [`sqrt`](@ref) function throws a [`DomainError`](@ref) if applied to a negative
real value:
Expand Down

0 comments on commit 52f27a7

Please sign in to comment.