Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Commit

Permalink
julia: add AbstractMXError as parent type
Browse files Browse the repository at this point in the history
  • Loading branch information
iblislin committed Sep 22, 2019
1 parent 89cb4ad commit 801f0c9
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 7 deletions.
31 changes: 31 additions & 0 deletions julia/exceptions.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.


"""
Exception thrown when an error occurred calling MXNet API.
"""
abstract type AbstractMXError <: Exception end

"General MXNet API error"
struct MXError <: AbstractMXError
msg::String

MXError(s::AbstractString) = new(string(s))
end

Base.show(io::IO, e::AbstractMXError) = print(io, e.msg)
5 changes: 5 additions & 0 deletions julia/src/MXNet.jl
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ import Base.Iterators: filter
# exports
###############################################################################

# exceptions.jl
export AbstractMXError,
MXError

# symbolic-node.jl
export SymbolicNode,
Variable,
Expand Down Expand Up @@ -135,6 +139,7 @@ export to_graphviz
# includes
###############################################################################

include("exceptions.jl")
include("base.jl")

include("runtime.jl")
Expand Down
7 changes: 0 additions & 7 deletions julia/src/base.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,6 @@
# specific language governing permissions and limitations
# under the License.

"Exception thrown when an error occurred calling MXNet API."
struct MXError <: Exception
msg :: AbstractString
end

Base.show(io::IO, e::MXError) = print(io, e.msg)

################################################################################
# Common types used in MXNet API
################################################################################
Expand Down

0 comments on commit 801f0c9

Please sign in to comment.