2021-10-17 18:26:00 +02:00
|
|
|
---
|
|
|
|
title: Part.raise.error()
|
|
|
|
---
|
2021-08-25 16:09:31 +02:00
|
|
|
|
2021-09-25 17:53:09 +02:00
|
|
|
A part's `raise.error()` method will log a error-level event.
|
|
|
|
Unlike other raised events which have no side-effects, if there is one or more
|
|
|
|
events of type `error`, the pattern will not be completed.
|
|
|
|
In other words, you should only use this when end up in a situation
|
|
|
|
you cannot recover from. If not, [raise a warning](/reference/api/part/raise/warning).
|
2021-08-25 16:09:31 +02:00
|
|
|
|
2021-09-25 17:53:09 +02:00
|
|
|
<Tip>
|
2021-08-25 16:09:31 +02:00
|
|
|
|
2021-09-25 17:53:09 +02:00
|
|
|
All raise methods are available via [the shorthand method](/reference/api/part/shorthand)
|
2021-08-25 16:09:31 +02:00
|
|
|
|
2021-09-25 17:53:09 +02:00
|
|
|
</Tip>
|
2021-08-25 16:09:31 +02:00
|
|
|
|
2021-09-25 17:53:09 +02:00
|
|
|
## Part.raise.error() signature
|
2021-08-25 16:09:31 +02:00
|
|
|
|
2021-09-25 17:53:09 +02:00
|
|
|
```js
|
|
|
|
raise.error(data)
|
|
|
|
```
|
2021-08-25 16:09:31 +02:00
|
|
|
|
2021-09-25 17:53:09 +02:00
|
|
|
## Part.raise.error() example
|
2021-08-25 16:09:31 +02:00
|
|
|
|
2021-09-25 17:53:09 +02:00
|
|
|
```js
|
|
|
|
export default function (part) {
|
|
|
|
const { raise, measurements } = part.shorthand()
|
|
|
|
|
|
|
|
if (measurements.hips > measurements.chest) {
|
|
|
|
raise.warning('Chest circumference smaller than hip circumference is currently unsupported. Aborting.')
|
|
|
|
return part
|
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
2021-10-17 18:26:00 +02:00
|
|
|
|