diff options
| author | ruki <[email protected]> | 2016-07-31 18:44:06 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2016-07-31 18:44:18 +0800 |
| commit | de05bd361137a2971875f9ba4d30cea926823913 (patch) | |
| tree | ae2df01a1b269099795aa992593df38f938a485c /xmake/core/base/string.lua | |
| parent | 68b869763491ff6eb97085b8536ef1b7c72fd2bd (diff) | |
try to format errors and add uuid interface
Diffstat (limited to 'xmake/core/base/string.lua')
| -rw-r--r-- | xmake/core/base/string.lua | 12 |
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 |
