From 4b38ff9d724c6f7901a0608b97c02043248a053e Mon Sep 17 00:00:00 2001 From: Quinton Miller Date: Sat, 16 Nov 2024 19:19:24 +0800 Subject: [PATCH] Add note about locale-dependent system error messages (#15196) `WasiError#message` is implemented entirely in Crystal and locale-independent. --- src/errno.cr | 5 ++++- src/winerror.cr | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/errno.cr b/src/errno.cr index 9d608c80bc1b..c519a8ab9fdb 100644 --- a/src/errno.cr +++ b/src/errno.cr @@ -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 diff --git a/src/winerror.cr b/src/winerror.cr index fbb2fb553873..844df5b07315 100644 --- a/src/winerror.cr +++ b/src/winerror.cr @@ -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 }