pnor_partition_table: Raise exception for unmapped offsets

Allow reads and writes of offsets that don't map onto partitions defined
in the ToC. Do so by ignoring the mapping failure and filling a window
with 0xff in the hole from the requested offset to the following
partition.

This change also removes the reliance on InternalFailure as the
exception of choice for communicating failures. We can do better without
the teeth-pulling required by phosphor-logging by translating custom
exceptions into phosphor-logging exceptions at the edges.

Change-Id: Ibfa961a66b0b979354c6dc226ccbe7e9fbafc16d
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
diff --git a/pnor_partition_table.cpp b/pnor_partition_table.cpp
index c9ef3a3..50d7d59 100644
--- a/pnor_partition_table.cpp
+++ b/pnor_partition_table.cpp
@@ -149,13 +149,15 @@
         {
             return part;
         }
+
+        /* Are we in a hole between partitions? */
+        if (blockOffset < part.data.base)
+        {
+            throw UnmappedOffset(offset, part.data.base * blockSize);
+        }
     }
 
-    MSG_ERR("Partition corresponding to offset 0x%zx not found", offset);
-    elog<InternalFailure>();
-
-    static pnor_partition p{};
-    return p;
+    throw UnmappedOffset(offset, pnorSize);
 }
 
 const pnor_partition& Table::partition(const std::string& name) const
@@ -170,10 +172,9 @@
         }
     }
 
-    MSG_ERR("Partition '%s' not found", name.c_str());
-    elog<InternalFailure>();
-    static pnor_partition p{};
-    return p;
+    std::stringstream err;
+    err << "Partition " << name << " is not listed in the table of contents";
+    throw UnknownPartition(err.str());
 }
 
 } // namespace partition