OpenCores
URL https://opencores.org/ocsvn/soc_maker/soc_maker/trunk

Subversion Repositories soc_maker

[/] [soc_maker/] [trunk/] [lib/] [soc_maker/] [err.rb] - Diff between revs 7 and 8

Only display areas with differences | Details | Blame | View Log

Rev 7 Rev 8
###############################################################
###############################################################
#
#
#  File:      err.rb
#  File:      err.rb
#
#
#  Author:    Christian Hättich
#  Author:    Christian Hättich
#
#
#  Project:   System-On-Chip Maker
#  Project:   System-On-Chip Maker
#
#
#  Target:    Linux / Windows / Mac
#  Target:    Linux / Windows / Mac
#
#
#  Language:  ruby
#  Language:  ruby
#
#
#
#
###############################################################
###############################################################
#
#
#
#
#   Copyright (C) 2014  Christian Hättich  - feddischson [ at ] opencores.org
#   Copyright (C) 2014  Christian Hättich  - feddischson [ at ] opencores.org
#
#
#   This program is free software: you can redistribute it and/or modify
#   This program is free software: you can redistribute it and/or modify
#   it under the terms of the GNU General Public License as published by
#   it under the terms of the GNU General Public License as published by
#   the Free Software Foundation, either version 3 of the License, or
#   the Free Software Foundation, either version 3 of the License, or
#   (at your option) any later version.
#   (at your option) any later version.
#
#
#   This program is distributed in the hope that it will be useful,
#   This program is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU General Public License for more details.
#   GNU General Public License for more details.
#
#
#   You should have received a copy of the GNU General Public License
#   You should have received a copy of the GNU General Public License
#   along with this program.  If not, see .
#   along with this program.  If not, see .
#
#
#
#
###############################################################
###############################################################
#
#
#   Description:
#   Description:
#     Error definitions and functions, which are used via mixins.
#     Error definitions and functions, which are used via mixins.
#
#
#
#
###############################################################
###############################################################
module SOCMaker
module SOCMaker
  #
  #
  # This sub-module contains some error-functionallity,
  # This sub-module contains some error-functionallity,
  # which is used in different classes via mixins.
  # which is used in different classes via mixins.
  #
  #
  # serr_if  means  raise Structure ERRor IF ...
  # serr_if  means  raise Structure ERRor IF ...
  # verr_if  means  raise Value ERRor IF ...
  # verr_if  means  raise Value ERRor IF ...
  # lerr_if  means  raise Library ERRor IF ...
  # lerr_if  means  raise Library ERRor IF ...
  # perr_if  mean   raise Processing ERRor IF
  # perr_if  mean   raise Processing ERRor IF
  module ERR
  module ERR
    class YAMLParseError < RuntimeError
    class YAMLParseError < RuntimeError
    end
    end
    class StructureError < RuntimeError
    class StructureError < RuntimeError
      attr :name
      attr :name
      attr :field
      attr :field
      def initialize( name, field, message )
      def initialize( name, field, message )
        super message
        super message
        @name   = name
        @name   = name
        @field  = field
        @field  = field
       # p message
       # p message
        SOCMaker::logger.error( "StructureError raised: " + message + " (#{name},#{field})" )
        SOCMaker::logger.error( "StructureError raised: " + message + " (#{name},#{field})" )
      end
      end
      def to_s
      def to_s
        "->#{@name}:#{@field}"
        "#{super} -> #{@name}:#{@field}"
      end
      end
    end
    end
    class LibError < RuntimeError
    class LibError < RuntimeError
      attr :name
      attr :name
      def initialize( requested, message )
      def initialize( requested, message )
        super message
        super message
        @name = requested
        @name = requested
        SOCMaker::logger.error( "LibError raised: " + message + " (#{requested})" )
        SOCMaker::logger.error( "LibError raised: " + message + " (#{requested})" )
      end
      end
      def to_s
      def to_s
        "->#{@name}"
        "#{super} -> #{@name}:#{@field}"
      end
      end
    end
    end
    class ProcessingError < RuntimeError
    class ProcessingError < RuntimeError
      def initialize( message )
      def initialize( message )
        super message
        super message
        SOCMaker::logger.error( "ProcessingError raised: " + message )
        SOCMaker::logger.error( "ProcessingError raised: " + message )
      end
      end
    end
    end
    class ValueError < RuntimeError
    class ValueError < RuntimeError
      attr :name
      attr :name
      attr :field
      attr :field
      def initialize( name, field, message )
      def initialize( name, field, message )
        super message
        super message
        @name = name
        @name = name
        @field = field
        @field = field
        SOCMaker::logger.error( "ValueError raised: " + message + " (#{name},#{field})" )
        SOCMaker::logger.error( "ValueError raised: " + message + " (#{name},#{field})" )
      end
      end
      def to_s
      def to_s
        "->#{@name}:#{@field}"
        "#{super} -> #{@name}:#{@field}"
      end
      end
    end
    end
    def serr_if( res, msg, o={} )
    def serr_if( res, msg, o={} )
      o = { instance: '??', field: '??' }.merge( o )
      o = { instance: '??', field: '??' }.merge( o )
      if !!( res )
      if !!( res )
        raise  StructureError.new( o[:instance], o[:field], msg )
        raise  StructureError.new( o[:instance], o[:field], msg )
      end
      end
    end
    end
    def verr_if( res, msg, o={})
    def verr_if( res, msg, o={})
      o = { instance: '??', field: '??' }.merge( o )
      o = { instance: '??', field: '??' }.merge( o )
      if !!( res )
      if !!( res )
        raise ValueError.new( o[:instance], o[:field], msg )
        raise ValueError.new( o[:instance], o[:field], msg )
      end
      end
    end
    end
    def lerr_if( res, msg, o={})
    def lerr_if( res, msg, o={})
      o = { requested: '??' }.merge( o )
      o = { requested: '??' }.merge( o )
      if !!( res )
      if !!( res )
        raise LibError.new( o[:requested], msg )
        raise LibError.new( o[:requested], msg )
      end
      end
    end
    end
    def perr_if( res, msg )
    def perr_if( res, msg )
      if !!( res )
      if !!( res )
        raise ProcessingError.new( msg )
        raise ProcessingError.new( msg )
      end
      end
    end
    end
  end # module ERR
  end # module ERR
end # module SOCMaker
end # module SOCMaker
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.