This repository was archived by the owner on Nov 17, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 5 files changed +81
-7
lines changed Expand file tree Collapse file tree 5 files changed +81
-7
lines changed Original file line number Diff line number Diff line change 17
17
18
18
# v1.6.0
19
19
20
+ * Add an abstract type ` AbstractMXError ` as the parent type for all MXNet-related
21
+ API errors. (#16235 )
22
+
20
23
21
24
# v1.5.0
22
25
Original file line number Diff line number Diff line change @@ -43,6 +43,10 @@ import Base.Iterators: filter
43
43
# exports
44
44
# ##############################################################################
45
45
46
+ # exceptions.jl
47
+ export AbstractMXError,
48
+ MXError
49
+
46
50
# symbolic-node.jl
47
51
export SymbolicNode,
48
52
Variable,
@@ -135,6 +139,7 @@ export to_graphviz
135
139
# includes
136
140
# ##############################################################################
137
141
142
+ include (" exceptions.jl" )
138
143
include (" base.jl" )
139
144
140
145
include (" runtime.jl" )
Original file line number Diff line number Diff line change 15
15
# specific language governing permissions and limitations
16
16
# under the License.
17
17
18
- " Exception thrown when an error occurred calling MXNet API."
19
- struct MXError <: Exception
20
- msg :: AbstractString
21
- end
22
-
23
- Base. show (io:: IO , e:: MXError ) = print (io, e. msg)
24
-
25
18
# ###############################################################################
26
19
# Common types used in MXNet API
27
20
# ###############################################################################
Original file line number Diff line number Diff line change
1
+ # Licensed to the Apache Software Foundation (ASF) under one
2
+ # or more contributor license agreements. See the NOTICE file
3
+ # distributed with this work for additional information
4
+ # regarding copyright ownership. The ASF licenses this file
5
+ # to you under the Apache License, Version 2.0 (the
6
+ # "License"); you may not use this file except in compliance
7
+ # with the License. You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing,
12
+ # software distributed under the License is distributed on an
13
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ # KIND, either express or implied. See the License for the
15
+ # specific language governing permissions and limitations
16
+ # under the License.
17
+
18
+
19
+ """
20
+ Exception thrown when an error occurred calling MXNet API.
21
+ """
22
+ abstract type AbstractMXError <: Exception end
23
+
24
+ " General MXNet API error"
25
+ struct MXError <: AbstractMXError
26
+ msg:: String
27
+
28
+ MXError (s:: AbstractString ) = new (string (s))
29
+ end
30
+
31
+ Base. show (io:: IO , e:: AbstractMXError ) = print (io, e. msg)
Original file line number Diff line number Diff line change
1
+ # Licensed to the Apache Software Foundation (ASF) under one
2
+ # or more contributor license agreements. See the NOTICE file
3
+ # distributed with this work for additional information
4
+ # regarding copyright ownership. The ASF licenses this file
5
+ # to you under the Apache License, Version 2.0 (the
6
+ # "License"); you may not use this file except in compliance
7
+ # with the License. You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing,
12
+ # software distributed under the License is distributed on an
13
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ # KIND, either express or implied. See the License for the
15
+ # specific language governing permissions and limitations
16
+ # under the License.
17
+
18
+ module TestExceptions
19
+
20
+ using MXNet
21
+ using Test
22
+
23
+ struct MXError′ <: AbstractMXError
24
+ msg:: String
25
+ end
26
+
27
+ function test_show ()
28
+ @info " AbstractMXError::Base.show"
29
+
30
+ io = IOBuffer ()
31
+ e = MXError′ (" magic" )
32
+ print (io, e)
33
+ str = String (take! (io))
34
+ @test str == " magic"
35
+ end
36
+
37
+ @testset " Exception Test" begin
38
+ test_show ()
39
+ end
40
+
41
+
42
+ end # module TestExceptions
You can’t perform that action at this time.
0 commit comments