Skip to content

Commit

Permalink
Add note about locale-dependent system error messages (crystal-lang#1…
Browse files Browse the repository at this point in the history
…5196)

`WasiError#message` is implemented entirely in Crystal and locale-independent.
  • Loading branch information
HertzDevil authored Nov 16, 2024
1 parent 25faaad commit 4b38ff9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/errno.cr
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ enum Errno
{% end %}
{% end %}

# Convert an Errno to an error message
# Returns the system error message associated with this errno.
#
# NOTE: The result may depend on the current system locale. Specs and
# comparisons should use `#value` instead of this method.
def message : String
unsafe_message { |slice| String.new(slice) }
end
Expand Down
3 changes: 3 additions & 0 deletions src/winerror.cr
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ enum WinError : UInt32
# using the current default `LANGID`.
#
# On non-win32 platforms the result is always an empty string.
#
# NOTE: The result may depend on the current system locale. Specs and
# comparisons should use `#value` instead of this method.
def message : String
{% if flag?(:win32) %}
unsafe_message { |slice| String.from_utf16(slice).strip }
Expand Down

0 comments on commit 4b38ff9

Please sign in to comment.