Spec-Zone .ru
спецификации, руководства, описания, API
Spec-Zone .ru
спецификации, руководства, описания, API
Библиотека разработчика Mac Разработчик
Поиск

 

Эта страница руководства для  версии 10.9 Mac OS X

Если Вы выполняете различную версию  Mac OS X, просматриваете документацию локально:

Читать страницы руководства

Страницы руководства предназначаются как справочник для людей, уже понимающих технологию.

  • Чтобы изучить, как руководство организовано или узнать о синтаксисе команды, прочитайте страницу руководства для страниц справочника (5).

  • Для получения дополнительной информации об этой технологии, ищите другую документацию в Библиотеке Разработчика Apple.

  • Для получения общей информации о записи сценариев оболочки, считайте Shell, Пишущий сценарий Учебника для начинающих.



catch(n)                                    Tcl Built-In Commands                                   catch(n)



____________________________________________________________________________________________________________

NAME
       catch - Evaluate script and trap exceptional returns

SYNOPSIS
       catch script ?resultVarName? ?optionsVarName?
____________________________________________________________________________________________________________


DESCRIPTION
       The catch command may be used to prevent errors from aborting command interpretation.  The catch com-mand command
       mand calls the Tcl interpreter recursively to execute script, and always returns without  raising  an
       error, regardless of any errors that might occur while executing script.

       If  script  raises  an  error, catch will return a non-zero integer value corresponding to the excep-tional exceptional
       tional return code returned by evaluation of script.  Tcl defines the normal return code from  script
       evaluation to be zero (0), or TCL_OK.  Tcl also defines four exceptional return codes: 1 (TCL_ERROR),
       2 (TCL_RETURN), 3 (TCL_BREAK), and 4 (TCL_CONTINUE).  Errors during evaluation of a script are  indi-cated indicated
       cated  by a return code of TCL_ERROR.  The other exceptional return codes are returned by the return,
       break, and continue commands and in other special situations as documented.  Tcl packages can  define
       new  commands  that return other integer values as return codes as well, and scripts that make use of
       the return -code command can also have return codes other than the five defined by Tcl.

       If the resultVarName argument is given, then the variable it names is set to the result of the script
       evaluation.  When the return code from the script is 1 (TCL_ERROR), the value stored in resultVarName
       is an error message.  When the return code from the script is 0 (TCL_OK), the value stored in result-VarName resultVarName
       VarName is the value returned from script.

       If  the optionsVarName argument is given, then the variable it names is set to a dictionary of return |
       options returned by evaluation of script.  Tcl specifies two entries that are always defined  in  the |
       dictionary:  -code and -level.  When the return code from evaluation of script is not TCL_RETURN, the |
       value of the -level entry will be 0, and the value of the -code entry will be the same as the  return |
       code.   Only  when  the  return code is TCL_RETURN will the values of the -level and -code entries be |
       something else, as further described in the documentation for the return command.                     |

       When the return code from evaluation of script is TCL_ERROR, three additional entries are defined  in |
       the  dictionary  of  return options stored in optionsVarName: -errorinfo, -errorcode, and -errorline. |
       The value of the -errorinfo entry is a formatted stack trace containing more  information  about  the |
       context in which the error happened.  The formatted stack trace is meant to be read by a person.  The |
       value of the -errorcode entry is additional information about  the  error  stored  as  a  list.   The |
       -errorcode  value  is meant to be further processed by programs, and may not be particularly readable |
       by people.  The value of the -errorline entry is an integer indicating which line of script was being |
       evaluated  when  the error occurred.  The values of the -errorinfo and -errorcode entries of the most |
       recent error are also available as values of the global variables ::errorInfo and ::errorCode respec- |
       tively.                                                                                               |

       Tcl packages may provide commands that set other entries in the dictionary of return options, and the |
       return command may be used by scripts to set return options in addition to those defined above.

EXAMPLES
       The catch command may be used in an if to branch based on the success of a script.
              if { [catch {open $someFile w} fid] } {
                  puts stderr "Could not open $someFile for writing\n$fid"
                  exit 1
              }

       There are more complex examples of catch usage in the documentation for the return command.


SEE ALSO
       break(n), continue(n), dict(n), error(n), return(n), tclvars(n)


KEYWORDS
       catch, error



Tcl                                                  8.5                                            catch(n)

Сообщение о проблемах

Способ сообщить о проблеме с этой страницей руководства зависит от типа проблемы:

Ошибки содержания
Ошибки отчета в содержании этой документации к проекту Tcl.
Отчеты об ошибках
Сообщите об ошибках в функциональности описанного инструмента или API к Apple через Генератор отчетов Ошибки и к проекту Tcl через их страницу создания отчетов ошибки.
Форматирование проблем
Отчет, форматирующий ошибки в интерактивной версии этих страниц со ссылками на отзыв ниже.