public static void ThrowException(ParsingScript script, string excName1, string errorToken = "", string excName2 = "") { string msg = Translation.GetErrorString(excName1); if (!string.IsNullOrWhiteSpace(errorToken)) { msg = string.Format(msg, errorToken); string candidate = Translation.TryFindError(errorToken, script); if (!string.IsNullOrWhiteSpace(candidate) && !string.IsNullOrWhiteSpace(excName2)) { string extra = Translation.GetErrorString(excName2); msg += " " + string.Format(extra, candidate); } } if (!string.IsNullOrWhiteSpace(script.Filename)) { string fileMsg = Translation.GetErrorString("errorFile"); msg += Environment.NewLine + string.Format(fileMsg, script.Filename); } int lineNumber = -1; string line = script.GetOriginalLine(out lineNumber); if (lineNumber >= 0) { string lineMsg = Translation.GetErrorString("errorLine"); msg += string.IsNullOrWhiteSpace(script.Filename) ? Environment.NewLine : " "; msg += string.Format(lineMsg, lineNumber + 1, line.Trim()); } throw new ArgumentException(msg); }
public static void ThrowException(ParsingScript script, string excName1, string errorToken = "", string excName2 = "") { #if UNITY_EDITOR == false && UNITY_STANDALONE == false && __ANDROID__ == false && __IOS__ == false string msg = Translation.GetErrorString(excName1); #else string msg = excName1; #endif if (!string.IsNullOrWhiteSpace(errorToken)) { msg = string.Format(msg, errorToken); #if UNITY_EDITOR == false && UNITY_STANDALONE == false && __ANDROID__ == false && __IOS__ == false string candidate = Translation.TryFindError(errorToken, script); #else string candidate = null; #endif if (!string.IsNullOrWhiteSpace(candidate) && !string.IsNullOrWhiteSpace(excName2)) { #if UNITY_EDITOR == false && UNITY_STANDALONE == false && __ANDROID__ == false && __IOS__ == false string extra = Translation.GetErrorString(excName2); #else string extra = excName2; #endif msg += " " + string.Format(extra, candidate); } } if (!string.IsNullOrWhiteSpace(script.Filename)) { #if UNITY_EDITOR == false && UNITY_STANDALONE == false && __ANDROID__ == false && __IOS__ == false string fileMsg = Translation.GetErrorString("errorFile"); #else string fileMsg = "File: {0}."; #endif msg += Environment.NewLine + string.Format(fileMsg, script.Filename); } int lineNumber = -1; string line = script.GetOriginalLine(out lineNumber); if (lineNumber >= 0) { #if UNITY_EDITOR == false && UNITY_STANDALONE == false && __ANDROID__ == false && __IOS__ == false string lineMsg = Translation.GetErrorString("errorLine"); #else string lineMsg = "Line {0}: [{1}]"; #endif msg += string.IsNullOrWhiteSpace(script.Filename) ? Environment.NewLine : " "; msg += string.Format(lineMsg, lineNumber + 1, line.Trim()); } throw new ArgumentException(msg); }