blob: 0ba47d9964b83efbd775519fdcbca28ce32554da [file] [log] [blame]
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
using Org.Apache.REEF.Common.Client;
using Org.Apache.REEF.Common.Exceptions;
using Org.Apache.REEF.Utilities;
using System;
using System.Runtime.Serialization;
namespace Org.Apache.REEF.Bridge.Core.Common.Client.Events
{
internal sealed class WakeError : IWakeError
{
public WakeError(string id, string message) : this(id, message, Optional<byte[]>.Empty())
{
}
public WakeError(string id, string message, Optional<byte[]> data)
{
Id = id;
Message = message;
Data = data;
}
public string Id { get; }
public string Message { get; set; }
public Optional<string> Description { get; set; }
public Optional<string> Reason { get; set; }
public Optional<byte[]> Data { get; set; }
public Exception AsError()
{
if (Data.IsPresent())
{
Exception inner;
try
{
inner = (Exception)ByteUtilities.DeserializeFromBinaryFormat(Data.Value);
}
catch (SerializationException se)
{
inner = NonSerializableEvaluatorException.UnableToDeserialize(
"Exception from Evaluator was not able to be deserialized, returning a NonSerializableEvaluatorException.",
se);
}
return new JobException(Id, Message, inner);
}
else
{
return new JobException(Id, Message);
}
}
}
}