Skip to content

Error behaviour is difficult to program for #15

@realflash

Description

@realflash

At the moment do_xero_api_call() (and by extension do_xero_put_call) return the data you were looking for if successful or an error string if not. This is hard for the user to handle, as they have to examine the returned value each time to see what it is.

The code should either

  • die when something goes wrong, so that the caller has the option to trap and handle
  • return undef with an error message available separately
  • always return a hash with the result in one key and a possibly undefined error string in another

I personally prefer it dies, because the caller can then easily choose to either handle or re-throw, plus they have options around croak etc instead. Additionally the caller can't get it wrong by failing to check the results. Are there any calls which would result in undef naturally whereby returning undef would potentially be confusing as to whether an error had occurred or not?

Additionally there is this issue on RT to consider.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions