Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in
S src
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 59
    • Issues 59
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 3
    • Merge requests 3
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Operations
    • Operations
    • Incidents
    • Environments
  • Analytics
    • Analytics
    • CI/CD
    • Code Review
    • Issue
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OPAL
  • src
  • Issues
  • #748

Closed
Open
Created Dec 22, 2022 by snuverink_j@snuverink_jDeveloper

Improve error message for using protected keywords

Reported by @zhang_h:

An input like:

ring: Cyclotron, TYPE="RING", ...;

will generate an error:

Error>
Error> *** User error detected by function "OpalData::define()"
Error>     You cannot replace the object "RING".
Error>     You cannot replace the object "RING".

This is because ring is a protected keyword and can't be used as an object name. However, from the user perspective this seems not very clear.

The error message comes from OpalData.cpp:

        if (oldObject->isBuiltin()  ||  ! oldObject->canReplaceBy(newObject)) {
            throw OpalException("OpalData::define()",
                                "You cannot replace the object \"" + name + "\".");
        } else {

I propose to make a distinction between the two cases and change it to:

        if (oldObject->isBuiltin()) {
            throw OpalException("OpalData::define()",
                                "The keyword \"" + name + "\" is protected and can't be used to name an object.");
        else if (! oldObject->canReplaceBy(newObject)) {
            throw OpalException("OpalData::define()",
                                "You cannot replace the already defined object \"" + name + "\".");
        } // else not needed

Also it might be good not to have "name" in uppercase letters if the user writes it in lowercase, but I couldn't quickly find out where this happens.

Assignee
Assign to
2023.1
Milestone
2023.1
Assign milestone
Time tracking