private void ThrowPossibleResponseError(params ApiSentence[] responseSentences) { foreach (ApiSentence responseSentence in responseSentences) { ApiTrapSentence trapSentence = responseSentence as ApiTrapSentence; if (trapSentence != null) { //detect well known error responses and convert them to special exceptions if (trapSentence.Message.StartsWith("no such command")) { throw new TikNoSuchCommandException(this, trapSentence); } else if (trapSentence.Message.StartsWith("no such item")) { throw new TikNoSuchItemException(this, trapSentence); } else if (AlreadyWithSuchRegex.IsMatch(trapSentence.Message)) { throw new TikAlreadyHaveSuchItemException(this, trapSentence); } else { throw new TikCommandTrapException(this, trapSentence); } } ApiFatalSentence fatalSentence = responseSentence as ApiFatalSentence; if (fatalSentence != null) { throw new TikCommandFatalException(this, fatalSentence.Message); } } }
private void ThrowPossibleResponseError(params ApiSentence[] responseSentences) { foreach (ApiSentence responseSentence in responseSentences) { ApiTrapSentence trapSentence = responseSentence as ApiTrapSentence; if (trapSentence != null) { throw new TikCommandException(this, trapSentence); } ApiFatalSentence fatalSentence = responseSentence as ApiFatalSentence; if (fatalSentence != null) { throw new TikCommandException(this, fatalSentence.Message); } } }