File Coverage

lib/Finance/Robinhood/Error.pm
Criterion Covered Total %
statement 9 17 52.9
branch n/a
condition 0 2 0.0
subroutine 3 5 60.0
pod n/a
total 12 24 50.0


line stmt bran cond sub pod time code
1             package Finance::Robinhood::Error;
2              
3             =encoding utf-8
4              
5             =for stopwords watchlist watchlists untradable urls
6              
7             =head1 NAME
8              
9             Finance::Robinhood::Error - What You Find When Things Go Wrong
10              
11             =head1 SYNOPSIS
12              
13             use Finance::Robinhood;
14              
15             my $rh = Finance::Robinhood->new->login( 'timbob35', 'hunter3' ); # Wrong password
16             $rh || die $rh; # false value is retured; stringify it as a fatal error
17              
18             =head1 DESCRIPTION
19              
20             When this distribution has trouble with anything, this is returned.
21              
22             Error objects evaluate to untrue values.
23              
24             Error objects stringify to the contents of C or 'Unknown error.'
25              
26             =head1 METHODS
27              
28             =cut
29              
30             our $VERSION = '0.92_002';
31 1     1   9 use Mojo::Base-base, -signatures;
  1         2  
  1         6  
32 1     1   200 use Mojo::URL;
  1         2  
  1         5  
33 0     0     use overload 'bool' => sub ( $s, @ ) {0},
  0            
  0            
  0            
34 0   0 0     '""' => sub ( $s, @ ) { $s->detail // 'Unknown error.' },
  0            
  0            
  0            
35 1     1   131 fallback => 1;
  1         7  
  1         11  
36             #
37              
38             =head2 C
39              
40             warn $error->detail;
41              
42             Returns a string. If this is a failed API call, the message returned by the
43             service is here.
44              
45             =cut
46              
47             has _rh => undef => weak => 1;
48              
49             has ['detail'];
50              
51             =head1 LEGAL
52              
53             This is a simple wrapper around the API used in the official apps. The author
54             provides no investment, legal, or tax advice and is not responsible for any
55             damages incurred while using this software. This software is not affiliated
56             with Robinhood Financial LLC in any way.
57              
58             For Robinhood's terms and disclosures, please see their website at
59             https://robinhood.com/legal/
60              
61             =head1 LICENSE
62              
63             Copyright (C) Sanko Robinson.
64              
65             This library is free software; you can redistribute it and/or modify it under
66             the terms found in the Artistic License 2. Other copyrights, terms, and
67             conditions may apply to data transmitted through this module. Please refer to
68             the L section.
69              
70             =head1 AUTHOR
71              
72             Sanko Robinson Esanko@cpan.orgE
73              
74             =cut
75              
76             1;