Skip to content

Commit

Permalink
chore: add language identifiers
Browse files Browse the repository at this point in the history
  • Loading branch information
brnhensley committed May 29, 2023
1 parent 2d32808 commit 7033680
Showing 1 changed file with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ redirects:

## Syntax

```
```py
newrelic.agent.notice_error(error=None, attributes={}, expected=None, ignore=None, status_code=None, application=None)
```

Expand Down Expand Up @@ -58,7 +58,7 @@ If called outside of the context of a monitored web request or background task,
</td>

<td>
Optional and rarely used. A tuple containing exception information (exception_class, exception_instance, traceback) returned from [`sys.exc_info()`](https://docs.python.org/2/library/sys.html#sys.exc_info).
Optional and rarely used. A tuple containing exception information `(exception_class, exception_instance, traceback)` returned from [`sys.exc_info()`](https://docs.python.org/2/library/sys.html#sys.exc_info).
</td>
</tr>

Expand All @@ -78,8 +78,8 @@ If called outside of the context of a monitored web request or background task,
<td>
`expected`

_boolean, iterable[String], callable(exception_class, exception_instance, traceback)->boolean_
</td>
_boolean_, _iterable[String]_, _callable(exception_class, exception_instance, traceback)->boolean_
</td>_

<td>
Optional. Errors to mark as expected can be passed in as an iterable of strings in the form `module:class`. This value can also be a callable or a Boolean indicating whether the error is expected. These errors will be reported to the UI but will not affect Apdex score or error rate.
Expand All @@ -90,7 +90,7 @@ If called outside of the context of a monitored web request or background task,
<td>
`ignore`

_boolean, iterable[String], callable(exception_class, exception_instance, traceback)->boolean_
_boolean_, _iterable[String]_, _callable(exception_class_, _exception_instance, traceback)->boolean_
</td>

<td>
Expand All @@ -102,11 +102,11 @@ If called outside of the context of a monitored web request or background task,
<td>
`status_code`

_string, integer, callable(exception_class, exception_instance, traceback)_
_string_, _integer_, _callable(exception_class, exception_instance, traceback)_
</td>

<td>
Optional. The exception status code. This value can be a string, integer, or a callable that takes in exception information (exception_class, exception_instance, traceback) returned from [`sys.exc_info()`](https://docs.python.org/2/library/sys.html#sys.exc_info) and returns the status code as an integer.
Optional. The exception status code. This value can be a string, integer, or a callable that takes in exception information `(exception_class, exception_instance, traceback)` returned from [`sys.exc_info()`](https://docs.python.org/2/library/sys.html#sys.exc_info) and returns the status code as an integer.
</td>
</tr>

Expand Down Expand Up @@ -134,23 +134,23 @@ None.

In a large majority of cases, you won't need to pass any parameters. You would just call the following where you want to report an exception:

```
```py
newrelic.agent.notice_error()
```

### Example using boolean [#boolean-example]

An example of `notice_error` using a boolean value. This indicates that an error should be expected.

```
```py
newrelic.agent.notice_error(expected=True)
```

### Call with sys.exc_info() tuple and additional parameters [#complex-example]

An example of `notice_error` using `sys.exc_info()` data:

```
```py
def complex_ignore_errors(exc, val, tb):
# do some logic here
return False
Expand All @@ -162,7 +162,7 @@ newrelic.agent.notice_error(attributes={'my_special_exception': True}, ignore=co

If you need to filter exceptions dynamically based on the attributes of a specific exception type, you can supply a callback function:

```
```py
def _ignore_errors(exc, value, tb):
if instance(value, HTTPError):
if value.status == 404:
Expand All @@ -171,4 +171,4 @@ def _ignore_errors(exc, value, tb):
newrelic.agent.notice_error(ignore=_ignore_errors)
```

If the exception is to be ignored/expected, set the return value for the callable to `True`. Return `False` if the exception should never be ignored/ expected regardless of any other checks, and `None` if subsequent checks and inbuilt rules should determine if the exception should be ignored/ expected. A callback would normally return either `True` or `None`.
If the exception is to be ignored/expected, set the return value for the callable to `True`. Return `False` if the exception should never be ignored/ expected regardless of any other checks, and `None` if subsequent checks and inbuilt rules should determine if the exception should be ignored/expected. A callback would normally return either `True` or `None`.

0 comments on commit 7033680

Please sign in to comment.