summaryrefslogtreecommitdiff
path: root/xmake/core/base/string.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2016-07-31 18:44:06 +0800
committerruki <[email protected]>2016-07-31 18:44:18 +0800
commitde05bd361137a2971875f9ba4d30cea926823913 (patch)
treeae2df01a1b269099795aa992593df38f938a485c /xmake/core/base/string.lua
parent68b869763491ff6eb97085b8536ef1b7c72fd2bd (diff)
try to format errors and add uuid interface
Diffstat (limited to 'xmake/core/base/string.lua')
-rw-r--r--xmake/core/base/string.lua12
1 files changed, 12 insertions, 0 deletions
diff --git a/xmake/core/base/string.lua b/xmake/core/base/string.lua
index ad178895b..22a84d9f4 100644
--- a/xmake/core/base/string.lua
+++ b/xmake/core/base/string.lua
@@ -136,5 +136,17 @@ function string:less(other)
return string.strcmp(self, other) < 0
end
+-- try to format
+function string.tryformat(format, ...)
+
+ -- attempt to format it
+ local ok, str = pcall(string.format, format, ...)
+ if ok then
+ return str
+ else
+ return format
+ end
+end
+
-- return module: string
return string