1 | // Copyright © SixtyFPS GmbH <info@slint.dev> |
2 | // SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-1.1 OR LicenseRef-Slint-commercial |
3 | |
4 | use pyo3::PyErr; |
5 | |
6 | pub struct PyGetPropertyError(pub slint_interpreter::GetPropertyError); |
7 | |
8 | impl From<PyGetPropertyError> for PyErr { |
9 | fn from(err: PyGetPropertyError) -> Self { |
10 | pyo3::exceptions::PyValueError::new_err(args:err.0.to_string()) |
11 | } |
12 | } |
13 | |
14 | impl From<slint_interpreter::GetPropertyError> for PyGetPropertyError { |
15 | fn from(err: slint_interpreter::GetPropertyError) -> Self { |
16 | Self(err) |
17 | } |
18 | } |
19 | |
20 | pub struct PySetPropertyError(pub slint_interpreter::SetPropertyError); |
21 | |
22 | impl From<PySetPropertyError> for PyErr { |
23 | fn from(err: PySetPropertyError) -> Self { |
24 | pyo3::exceptions::PyValueError::new_err(args:err.0.to_string()) |
25 | } |
26 | } |
27 | |
28 | impl From<slint_interpreter::SetPropertyError> for PySetPropertyError { |
29 | fn from(err: slint_interpreter::SetPropertyError) -> Self { |
30 | Self(err) |
31 | } |
32 | } |
33 | |
34 | pub struct PyPlatformError(pub slint_interpreter::PlatformError); |
35 | |
36 | impl From<PyPlatformError> for PyErr { |
37 | fn from(err: PyPlatformError) -> Self { |
38 | pyo3::exceptions::PyRuntimeError::new_err(args:err.0.to_string()) |
39 | } |
40 | } |
41 | |
42 | impl From<slint_interpreter::PlatformError> for PyPlatformError { |
43 | fn from(err: slint_interpreter::PlatformError) -> Self { |
44 | Self(err) |
45 | } |
46 | } |
47 | |
48 | pub struct PyEventLoopError(pub slint_interpreter::EventLoopError); |
49 | |
50 | impl From<PyEventLoopError> for PyErr { |
51 | fn from(err: PyEventLoopError) -> Self { |
52 | pyo3::exceptions::PyRuntimeError::new_err(args:err.0.to_string()) |
53 | } |
54 | } |
55 | |
56 | impl From<slint_interpreter::EventLoopError> for PyEventLoopError { |
57 | fn from(err: slint_interpreter::EventLoopError) -> Self { |
58 | Self(err) |
59 | } |
60 | } |
61 | |
62 | pub struct PyInvokeError(pub slint_interpreter::InvokeError); |
63 | |
64 | impl From<PyInvokeError> for PyErr { |
65 | fn from(err: PyInvokeError) -> Self { |
66 | pyo3::exceptions::PyRuntimeError::new_err(args:err.0.to_string()) |
67 | } |
68 | } |
69 | |
70 | impl From<slint_interpreter::InvokeError> for PyInvokeError { |
71 | fn from(err: slint_interpreter::InvokeError) -> Self { |
72 | Self(err) |
73 | } |
74 | } |
75 | |
76 | pub struct PySetCallbackError(pub slint_interpreter::SetCallbackError); |
77 | |
78 | impl From<PySetCallbackError> for PyErr { |
79 | fn from(err: PySetCallbackError) -> Self { |
80 | pyo3::exceptions::PyRuntimeError::new_err(args:err.0.to_string()) |
81 | } |
82 | } |
83 | |
84 | impl From<slint_interpreter::SetCallbackError> for PySetCallbackError { |
85 | fn from(err: slint_interpreter::SetCallbackError) -> Self { |
86 | Self(err) |
87 | } |
88 | } |
89 | |
90 | pub struct PyLoadImageError(pub slint_interpreter::LoadImageError); |
91 | |
92 | impl From<PyLoadImageError> for PyErr { |
93 | fn from(err: PyLoadImageError) -> Self { |
94 | pyo3::exceptions::PyRuntimeError::new_err(args:err.0.to_string()) |
95 | } |
96 | } |
97 | |
98 | impl From<slint_interpreter::LoadImageError> for PyLoadImageError { |
99 | fn from(err: slint_interpreter::LoadImageError) -> Self { |
100 | Self(err) |
101 | } |
102 | } |
103 | |
104 | pub struct PyColorParseError(pub css_color_parser2::ColorParseError); |
105 | |
106 | impl From<PyColorParseError> for PyErr { |
107 | fn from(err: PyColorParseError) -> Self { |
108 | pyo3::exceptions::PyRuntimeError::new_err(args:err.0.to_string()) |
109 | } |
110 | } |
111 | |
112 | impl From<css_color_parser2::ColorParseError> for PyColorParseError { |
113 | fn from(err: css_color_parser2::ColorParseError) -> Self { |
114 | Self(err) |
115 | } |
116 | } |
117 | |