| 1 |
/** |
| 2 |
* This Error adds a property of errors, |
| 3 |
* so we can catch a types error and loop through all the errors from the server. |
| 4 |
* |
| 5 |
* @since 3.0.0 |
| 6 |
*/ |
| 7 |
class FormRequestError extends Error { |
| 8 |
public errors: Array<object>; |
| 9 |
|
| 10 |
constructor(errors: Array<object>, ...params) { |
| 11 |
// Pass remaining arguments (including vendor specific ones) to parent constructor |
| 12 |
super(...params); |
| 13 |
|
| 14 |
// Maintains proper stack trace for where our error was thrown (only available on V8) |
| 15 |
if (Error.captureStackTrace) { |
| 16 |
Error.captureStackTrace(this, FormRequestError); |
| 17 |
} |
| 18 |
|
| 19 |
this.name = 'FormRequestError'; |
| 20 |
this.errors = errors; |
| 21 |
} |
| 22 |
} |
| 23 |
|
| 24 |
export default FormRequestError; |
| 25 |
|