github.com/emcfarlane/larking@v0.0.0-20220605172417-1704b45ee6c3/starlib/starlarkerrors/README.md (about)

     1  ## error
     2  
     3  `error(*args, **kwargs)` creates a new error.
     4  
     5  | Parameter | Type | Description |
     6  | --------- | ---- | ----------- |
     7  | *args | []any | Args like `print`. |
     8  | **kwargs | {}any | Kwargs like `print`. |
     9  
    10  ### error·matches
    11  
    12  `e.matches(pattern)` returns `True` if the regex pattern matches the error string.
    13  
    14  | Parameter | Type | Description |
    15  | --------- | ---- | ----------- |
    16  | pattern | string | Regex pattern to match. |
    17  
    18  ### error·kind
    19  
    20  `e.kind(err)` returns `True` if the error is of the same kind as `err`.
    21  
    22  | Parameter | Type | Description |
    23  | --------- | ---- | ----------- |
    24  | err | error | Error to compare against. |
    25  
    26  
    27  ## catch
    28  
    29  `catch(fn, *args, **kwargs)`
    30  evaluates the provided function and returns a result.
    31  Catch allows starlark code to capture errors returned from a function call.
    32  The `function` must be a callable that accepts the remaining args and kwargs passed to catch.
    33  
    34  | Parameter | Type | Description |
    35  | --------- | ---- | ----------- |
    36  | fn | function | Function to call. |
    37  | *args | []any | Args for `fn`. |
    38  | **kwargs | {}any | Kwargs for `fn`. |