question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

What is the reason error property is boolean?

See original GitHub issue

as opposed to an instance of Error object. Boolean flag is vague. It just says what the error is and does not standardise the method of getting error description. Docs say that payload by convention should be an Error object.

Issue Analytics

  • State:open
  • Created 8 years ago
  • Comments:19

github_iconTop GitHub Comments

8reactions
bryanlarsencommented, Oct 15, 2015

The error design of Flux Standard Actions is completely unworkable for us; we’ve decided to not use Flux Standard Actions for that reason.

  1. As mentioned, the ‘error’ boolean is redundant. For us, an error is any action that has a type that ends with ‘ERROR’.
  2. We almost always require the original payload when handling error actions. For example, when we have an error updating a model, we update our state to contain the list of field that have not been successfully updated. It’s certainly possible to put the original payload into meta.payload or payload.payload or something like that, but that’s just silly. In our “FSA”, the payload property of an error action is always the original payload.
  3. Given that most error objects are the result of HTTP actions, we have a standard field that contains the HTTP status code. Not all errors have to have this field, but when they do, it’s in a standard place.
  4. We make the Error object required rather than optional, and put it in the error property of the action.
2reactions
miguelollercommented, Jul 1, 2016

I think the original intent of adding error as a boolean property can be deduced from the example in the readme.

{
  type: 'ADD_TODO',
  payload: {
    text: 'Do something.'  
  }
}

{
  type: 'ADD_TODO',
  payload: new Error(),
  error: true
}

There are no redundancies in this example.

Due to the way people use Redux, though, it starts to get redundant.

{
  type: 'ADD_TODO_REQUEST',
  payload: {
    text: 'Do something.'  
  }
}

{
  type: 'ADD_TODO_SUCCESS',
  payload: {
    text: 'Do something.'
  }
}

{
  type: 'ADD_TODO_FAILURE',
  payload: new Error(),
  error: true
}

Perhaps the correct approach would be to separate app concerns from asynchronous concerns and instead of doing request -> success | failure, it’s better to do request -> success (triggers action<foo>) | failure (triggers error<foo>), where action<foo> is equivalent to { type: 'foo' } and error<foo> is equivalent to { type: 'foo', error: true } with their respective payloads.

The only issue this brings are optimistic updates. This could be solved, though, by triggering actions that queue the change when the request is made and then committing when it succeeds or reverting if it fails.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unknown boolean property: " + fieldName + " - Opster
A detailed guide on how to resolve errors related to "Unknown boolean property: " + fieldName + ""
Read more >
why does accessing a property of a boolean value not throw ...
It's because false itself is an object, while undefined isn't. Variable is undefined if it wasn't assigned a value yet, like foo2 in...
Read more >
Solving the Boolean Identity Crisis: Part 3 | Programming Elm
In this post, you learned that boolean properties can cause invalid state configurations, which create bugs that the compiler can't catch.
Read more >
Error thrown. Attempt to modify property “response” on bool?
I received a critical error email form WordPress earlier today. Since WordPress 5.2 there is a built-in feature that detects when a plugin...
Read more >
Boolean in custom policy give invalid type error
I had the same error caused by setting the wrong data type when creating the User attribute in the Azure portal ( ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found