• Guides
  • Videos
  • Publications
  • API
  • Github
  • Community
  • Release Notes
  • Plugins
Installing Origen
  • Introduction
  • How to Install
  • How to Install (Windows)
  • Company Customization
  • Understanding Gems
  • Invoking Considerations
  • Workspace Management
Getting Started with Origen
  • Core concepts
  • Creating a New App
  • Directory Structure
  • The Initial Commit
  • Creating New Files
  • Understanding Blocks
  • Application Architecture
Runtime Environment
  • Introduction
  • Mode
  • Environment
  • Target
  • Production Targets
  • Global Setup
  • Load Order
  • Programming
Models
  • Introduction
  • Naming
  • Definition & Hierarchy
  • Adding Attributes
  • Versioning
  • Bugs & Features
  • Package, Mode & Configuration
  • Registers
  • Pins
  • Power Domains
  • Hardware Attributes
  • Parameters
  • Specifications
  • Fuses
  • Generic Components
  • Creating Your Own Components
Compiler (Views)
  • Introduction
  • Creating Templates
  • Using Sub-Templates
  • Helpers
  • Running The Compiler
  • Inline Compiler
Controllers
  • Introduction
  • Shadow Controllers
  • Direct Controllers
Pattern Generator
  • Introduction
  • Creating Patterns
  • Pins
  • Timing and Waiting
  • Registers
  • Documenting Patterns
  • Generating by Name
  • Common API
  • J750 API
  • V93K API
  • UltraFlex API
  • STIL & Other Formats
  • Custom Testers
  • Running The PatGen
  • Concurrent Patterns
Test Program Generator
  • Introduction
  • Philosophy
  • Creating Flows
  • Managing Flow Control
  • Creating an Interface
  • Additional Resources
  • Dynamic Custom Code
  • J750 API
  • V93K Common API
  • V93K SMT7 API
  • V93K SMT8 API
  • UltraFLEX API
  • Documenting the Program
  • Creating Custom Testers
  • Running the ProgGen
Simulation
  • Introduction
  • How It Works
  • Compiling the DUT
  • AMS Support
  • Environment Setup
  • Application Setup
  • Simulating Patterns
  • Simulating Flows
  • Direct DUT Manipulation
  • Simulator Log Output
  • Artifacts
  • Debugging
Documentation Generator
  • Introduction
  • Markdown
  • Linking
  • Styling
  • Testing
  • API Generation
  • Deploying
Plugins
  • Introduction
  • Using a Plugin
  • Creating a Plugin
  • Current Plugin
  • Dev Environment
  • Dev Considerations
  • Paths & Origen.root
  • Config & Origen.app
  • Miscellaneous Topics
Miscellaneous
  • Revision Control
  • Origen Remotes
  • Lint Testing
  • Session Store
  • LSF API
  • Users, Emails & Maillists
  • Utilities & Helpers
  • Ruby Extensions
  • Logger
  • Adding Commands
  • Overriding Commands
  • Callbacks
  • Application Callbacks
Advanced Topics
  • Introduction
  • Invocation Customization
  • Custom App Generators

Plugins

Miscellaneous Topics


Topics on this page relate to plugins in general but do not fit into any of the previous topics and are too minor in scope and content to warrant their own pages.

  • Failing the Application
  • Failing the Application

    Sometimes, the usage of your application or plugin is not correct, certain conditions are not met, or some other circumstance arises in which the application or plugin cannot continue. In these instances, the best course of action is to print the error message and exit the current process.

    Ruby provides a few methods to do this. Most commonly:

    • throw: raises an exception.
    • fail/raise: raises a runtime error.
    • exit: raises a SystemExit error but still runs ensure blocks and can be rescued.
    • exit!: kills the process immediately.

    Each of these has their place, but their usefulness is based primarily on the information you, as the developer, provide. For example, using exit! without any error message just kills the process, without any information going back to the user. fail can be used to dump a stack trace, but for those that aren’t power users, and especially for those who are newer to programming, this can be almost as bad as providing no details, with the exception of sending the stack trace to someone else.

    Information on the what, where, when, and why for failing and exiting the process is readily available online, both for Ruby and for programming in general. Discussions on those matters get into best practices, use cases, coding styles, etc., and are way out of the scope of this guide. What will be covered is how Origen can help you when you choose to exit the process and/or raise an exception.

    Origen provides two methods to help with this: Origen.app.fail, and Origen.app.fail!. The former behaves almost identically to the standard fail method, with the exception of accepting a hash instead of string, and prepending the current application that is calling Origen.app.fail.

    Note that these are Origen::Application instance methods, and Origen.app will always reference the application. For usage in plugins, Origen.app! should be used instead. See here for additional information.

    Origen.app!.name
      #=> my_app
    
    fail
      #=> RuntimeError with no message
    
    # Just fail the application, without adding details:
    Origen.app!.fail
      #=> RuntimeError with message: 'Fail in my_app'
    
    # Fail the application with some context:
    Origen.app!.fail(message: 'An unknown condition occured!')
      #=> RuntimeError with message: 'Fail in my_app: An unknown condition occured!'
    
    # Fail the application with some context and a custom exception:
    Origen.app!.fail(message: 'An unknown condition occured!', exception_class: StandardError)
      #=> StandardError with message: 'Fail in my_app: An unknown condition occured!'
    

    Note that exception_class should be a class object (of type class), not an instance of the class.

    Origen.app.fail! performs the same function as Origen.app.fail but raises a SystemExit and quits the process cleanly (no stack trace). It also prints the message using Origen’s Logger, instead of using the exception message to convey information.

    The key difference, however, is if the current process is run with debug enabled (using the -d or --debug command line options) then Origen.app.fail! behaves identically to Origen.app.fail. The intention is give a user-facing API a clean exit while displaying in the familiar Origen-logger format, while allowing users to generate more useful bug reports, or just for the curious user themselves to get more information.

    Origen.debugger_enabled?
      #=> false
    
    Origen.app!.name
      #=> :my_app
    
    Origen.app.fail!(message: 'An unknown condition occured!')
      #=> [ERROR]      0.009[0.009]    || Fail in my_app: An unknown condition occured!
      #=> *Process Terminates*
    
    Origen.debugger_enabled?
      #=> true
    
    Origen.app!.name
      #=> :my_app
    
    Origen.app.fail!(message: 'An unknown condition occured!')
      #=> RuntimeError with message: Fail in my_app: An unknown condition occured!
      #=> *Process terminates with #raise instead of #exit*
      #=> *Exception and stack trace printed to console*
    

    By default, the status of a process exited with Origen.app.fail! will be 1. You can provide an option exit_status to exit with that status instead.

    Full API documentation is available on the API


    Comments

    Generated with the Origen Semiconductor Developer's Kit

    Origen is released under the terms of the MIT license