diff options
Diffstat (limited to 'libbuild2/variable.txx')
-rw-r--r-- | libbuild2/variable.txx | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/libbuild2/variable.txx b/libbuild2/variable.txx index 9b7490a..92b7169 100644 --- a/libbuild2/variable.txx +++ b/libbuild2/variable.txx @@ -60,14 +60,27 @@ namespace build2 T convert (value&& v) { - if (v.type == nullptr) - return convert<T> (move (v).as<names> ()); - else if (v.type == &value_traits<T>::value_type) - return move (v).as<T> (); + if (v) + { + if (v.type == nullptr) + return convert<T> (move (v).as<names> ()); + else if (v.type == &value_traits<T>::value_type) + return move (v).as<T> (); + } - throw invalid_argument ( - string ("invalid ") + value_traits<T>::value_type.name + - " value: conversion from " + v.type->name); + string m ("invalid "); + m += value_traits<T>::value_type.name; + m += " value: "; + + if (v) + { + m += "conversion from "; + m += v.type->name; + } + else + m += "null"; + + throw invalid_argument (move (m)); } template <typename T> |