---
Product: psd
Platform: net
Page Type: docs
Canonical URL: https://docs.aspose.org/psd/net/developer-guide/core-exceptions
---

# Core Exceptions

How Aspose.PSD FOSS for .NET reports load and save errors through PsdLoadException and PsdSaveException.

## Overview

The library reports load and save failures through two dedicated exception types: `PsdLoadException` and `PsdSaveException`, both extending the standard `Exception` class.

---

### PsdLoadException

Thrown when `Image.Load()` / `PsdImage.Load()` cannot parse the input as a valid PSD or PSB document.

```csharp
try
{
    using var image = (PsdImage)Image.Load(inputPath);
}
catch (PsdLoadException ex)
{
    Console.WriteLine($"Failed to load {inputPath}: {ex.Message}");
}
```

### PsdSaveException

Thrown when `PsdImage.Save()` cannot write the document out.

```csharp
try
{
    image.Save(outputPath);
}
catch (PsdSaveException ex)
{
    Console.WriteLine($"Failed to save {outputPath}: {ex.Message}");
}
```

---

### Constructors

Both exception types have the same two-constructor shape: a message-only constructor, and a message-plus-inner-exception constructor for wrapping a lower-level failure.

```csharp
throw new PsdLoadException("Unexpected end of stream while reading the PSD header.");
throw new PsdSaveException("Failed to write layer data.", innerException);
```

---

### Tips and Best Practices

- Catch `PsdLoadException` around every `Image.Load()`/`PsdImage.Load()` call that processes external input.
- Catch `PsdSaveException` around every `PsdImage.Save()` call if the destination (disk, stream) might not be writable.
- Both types extend `Exception`, so a broader `catch (Exception)` also catches them — prefer the specific types when you want to distinguish load failures from save failures.

---

### Common Issues

| Issue | Cause | Fix |
|---|---|---|
| `PsdLoadException` on a file that opens fine in other tools | The input is not a valid PSD/PSB document, or uses a feature this FOSS build's parser does not recognize | Confirm the file is a genuine PSD/PSB document; report unsupported features separately from load failures |
| `PsdSaveException` when writing to a stream | The destination stream may not be writable or may have been disposed already | Confirm the stream is open and writable before calling `Save()` |

---

### FAQ

#### Does this library retry automatically after a load or save failure?

No. `PsdLoadException` and `PsdSaveException` are raised once and must be handled by the caller; there is no automatic retry.

#### Can I inspect the original cause of a wrapped exception?

Yes, when one is provided — both constructors accept an `innerException` parameter, accessible through the standard `Exception.InnerException` property.

---

### API Reference Summary

| Class/Method | Description |
|---|---|
| `PsdLoadException(message)` / `PsdLoadException(message, innerException)` | Thrown when a document cannot be loaded |
| `PsdSaveException(message)` / `PsdSaveException(message, innerException)` | Thrown when a document cannot be saved |

## See Also

- [Aspose.PSD — Enterprise Documentation](https://docs.aspose.com/psd/)