@@ -12,101 +12,111 @@ import org.readium.r2.testapp.utils.UserError
12
12
13
13
fun LcpError.toUserError (): UserError = when (this ) {
14
14
LcpError .LicenseInteractionNotAvailable ->
15
- UserError (R .string.lcp_error_license_interaction_not_available)
15
+ UserError (R .string.lcp_error_license_interaction_not_available, cause = this )
16
16
LcpError .LicenseProfileNotSupported ->
17
- UserError (R .string.lcp_error_license_profile_not_supported)
17
+ UserError (R .string.lcp_error_license_profile_not_supported, cause = this )
18
18
LcpError .CrlFetching ->
19
- UserError (R .string.lcp_error_crl_fetching)
19
+ UserError (R .string.lcp_error_crl_fetching, cause = this )
20
20
is LcpError .Network ->
21
- UserError (R .string.lcp_error_network)
21
+ UserError (R .string.lcp_error_network, cause = this )
22
22
23
23
is LcpError .Runtime ->
24
- UserError (R .string.lcp_error_runtime)
24
+ UserError (R .string.lcp_error_runtime, cause = this )
25
25
is LcpError .Unknown ->
26
- UserError (R .string.lcp_error_unknown)
26
+ UserError (R .string.lcp_error_unknown, cause = this )
27
27
28
28
is LcpError .Container ->
29
29
when (this ) {
30
30
is LcpError .Container .FileNotFound ->
31
- UserError (R .string.lcp_error_container_file_not_found)
31
+ UserError (R .string.lcp_error_container_file_not_found, cause = this )
32
32
LcpError .Container .OpenFailed ->
33
- UserError (R .string.lcp_error_container_open_failed)
33
+ UserError (R .string.lcp_error_container_open_failed, cause = this )
34
34
is LcpError .Container .ReadFailed ->
35
- UserError (R .string.lcp_error_container_read_failed)
35
+ UserError (R .string.lcp_error_container_read_failed, cause = this )
36
36
is LcpError .Container .WriteFailed ->
37
- UserError (R .string.lcp_error_container_write_failed)
37
+ UserError (R .string.lcp_error_container_write_failed, cause = this )
38
38
}
39
39
40
40
is LcpError .Decryption ->
41
41
when (this ) {
42
42
LcpError .Decryption .ContentDecryptError ->
43
- UserError (R .string.lcp_error_decryption_content_decrypt_error)
43
+ UserError (R .string.lcp_error_decryption_content_decrypt_error, cause = this )
44
44
LcpError .Decryption .ContentKeyDecryptError ->
45
- UserError (R .string.lcp_error_decryption_content_key_decrypt_error)
45
+ UserError (R .string.lcp_error_decryption_content_key_decrypt_error, cause = this )
46
46
}
47
47
48
48
is LcpError .LicenseIntegrity ->
49
49
when (this ) {
50
50
LcpError .LicenseIntegrity .CertificateRevoked ->
51
- UserError (R .string.lcp_error_license_integrity_certificate_revoked)
51
+ UserError (R .string.lcp_error_license_integrity_certificate_revoked, cause = this )
52
52
LcpError .LicenseIntegrity .InvalidCertificateSignature ->
53
- UserError (R .string.lcp_error_license_integrity_invalid_certificate_signature)
53
+ UserError (
54
+ R .string.lcp_error_license_integrity_invalid_certificate_signature,
55
+ cause = this
56
+ )
54
57
LcpError .LicenseIntegrity .InvalidLicenseSignature ->
55
- UserError (R .string.lcp_error_license_integrity_invalid_license_signature)
58
+ UserError (
59
+ R .string.lcp_error_license_integrity_invalid_license_signature,
60
+ cause = this
61
+ )
56
62
LcpError .LicenseIntegrity .InvalidLicenseSignatureDate ->
57
- UserError (R .string.lcp_error_license_integrity_invalid_license_signature_date)
63
+ UserError (
64
+ R .string.lcp_error_license_integrity_invalid_license_signature_date,
65
+ cause = this
66
+ )
58
67
LcpError .LicenseIntegrity .InvalidUserKeyCheck ->
59
- UserError (R .string.lcp_error_license_integrity_invalid_user_key_check)
68
+ UserError (R .string.lcp_error_license_integrity_invalid_user_key_check, cause = this )
60
69
}
61
70
62
71
is LcpError .LicenseStatus ->
63
72
when (this ) {
64
73
is LcpError .LicenseStatus .Cancelled ->
65
- UserError (R .string.lcp_error_license_status_cancelled, date)
74
+ UserError (R .string.lcp_error_license_status_cancelled, date, cause = this )
66
75
is LcpError .LicenseStatus .Expired ->
67
- UserError (R .string.lcp_error_license_status_expired, end)
76
+ UserError (R .string.lcp_error_license_status_expired, end, cause = this )
68
77
is LcpError .LicenseStatus .NotStarted ->
69
- UserError (R .string.lcp_error_license_status_not_started, start)
78
+ UserError (R .string.lcp_error_license_status_not_started, start, cause = this )
70
79
is LcpError .LicenseStatus .Returned ->
71
- UserError (R .string.lcp_error_license_status_returned, date)
80
+ UserError (R .string.lcp_error_license_status_returned, date, cause = this )
72
81
is LcpError .LicenseStatus .Revoked ->
73
82
UserError (
74
83
R .plurals.lcp_error_license_status_revoked,
75
84
devicesCount,
76
85
date,
77
- devicesCount
86
+ devicesCount,
87
+ cause = this
78
88
)
79
89
}
80
90
81
91
is LcpError .Parsing ->
82
92
when (this ) {
83
93
LcpError .Parsing .LicenseDocument ->
84
- UserError (R .string.lcp_error_parsing_license_document)
94
+ UserError (R .string.lcp_error_parsing_license_document, cause = this )
85
95
LcpError .Parsing .MalformedJSON ->
86
- UserError (R .string.lcp_error_parsing_malformed_json)
96
+ UserError (R .string.lcp_error_parsing_malformed_json, cause = this )
87
97
LcpError .Parsing .StatusDocument ->
88
- UserError (R .string.lcp_error_parsing_license_document)
98
+ UserError (R .string.lcp_error_parsing_license_document, cause = this )
89
99
else ->
90
- UserError (R .string.lcp_error_parsing)
100
+ UserError (R .string.lcp_error_parsing, cause = this )
91
101
}
92
102
93
103
is LcpError .Renew ->
94
104
when (this ) {
95
105
is LcpError .Renew .InvalidRenewalPeriod ->
96
- UserError (R .string.lcp_error_renew_invalid_renewal_period)
106
+ UserError (R .string.lcp_error_renew_invalid_renewal_period, cause = this )
97
107
LcpError .Renew .RenewFailed ->
98
- UserError (R .string.lcp_error_renew_renew_failed)
108
+ UserError (R .string.lcp_error_renew_renew_failed, cause = this )
99
109
LcpError .Renew .UnexpectedServerError ->
100
- UserError (R .string.lcp_error_renew_unexpected_server_error)
110
+ UserError (R .string.lcp_error_renew_unexpected_server_error, cause = this )
101
111
}
102
112
103
113
is LcpError .Return ->
104
114
when (this ) {
105
115
LcpError .Return .AlreadyReturnedOrExpired ->
106
- UserError (R .string.lcp_error_return_already_returned_or_expired)
116
+ UserError (R .string.lcp_error_return_already_returned_or_expired, cause = this )
107
117
LcpError .Return .ReturnFailed ->
108
- UserError (R .string.lcp_error_return_return_failed)
118
+ UserError (R .string.lcp_error_return_return_failed, cause = this )
109
119
LcpError .Return .UnexpectedServerError ->
110
- UserError (R .string.lcp_error_return_unexpected_server_error)
120
+ UserError (R .string.lcp_error_return_unexpected_server_error, cause = this )
111
121
}
112
122
}
0 commit comments