Skip to content

Safely access optionals when calling DAO methods #1276

Open
@wslulciuc

Description

@wslulciuc

We currently use get() directly on optionals when accessing rows (though they technically should exist in most cases). For example:

final NamespaceRow namespaceRow = NamespaceDao.findNamespaceByName().get()

We should move towards safely accessing the row value returned and throw an exception when not present (where applicable):

import marquez.db.exceptions.RowNotFoundException;
.
.
final NamespaceRow namespaceRow =
  NamespaceDao.findNamespaceByName()
     .orElseThrow(() -> new RowNotFoundException())

The exception can be mapped to a 500.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    • Status

      No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions