aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcrobibero <cody@robibe.ro>2020-11-13 11:14:44 -0700
committercrobibero <cody@robibe.ro>2020-11-13 11:14:44 -0700
commit5f52a58e785fa4ae06fa07a93b81c1e7547ac9f3 (patch)
tree68466ae2c11051e631a4cf06a43cf14da1f4d756
parentbe312f992d92433e3e7619e264889d1a0afadf26 (diff)
Convert NullReferenceException to ResourceNotFoundException
-rw-r--r--Emby.Server.Implementations/AppBase/ConfigurationHelper.cs5
-rw-r--r--Emby.Server.Implementations/Cryptography/CryptographyProvider.cs3
-rw-r--r--Emby.Server.Implementations/Session/WebSocketController.cs3
-rw-r--r--Jellyfin.Api/Controllers/DynamicHlsController.cs5
-rw-r--r--Jellyfin.Api/Controllers/EnvironmentController.cs3
-rw-r--r--Jellyfin.Api/Controllers/HlsSegmentController.cs3
-rw-r--r--Jellyfin.Api/Controllers/ItemLookupController.cs6
-rw-r--r--Jellyfin.Api/Controllers/RemoteImageController.cs6
-rw-r--r--Jellyfin.Api/Controllers/VideoHlsController.cs3
-rw-r--r--Jellyfin.Api/Helpers/AudioHelper.cs3
-rw-r--r--Jellyfin.Api/Helpers/DynamicHlsHelper.cs2
-rw-r--r--Jellyfin.Api/Helpers/HlsHelpers.cs3
-rw-r--r--Jellyfin.Api/Helpers/ProgressiveFileCopier.cs3
-rw-r--r--Jellyfin.Api/Helpers/StreamingHelpers.cs2
-rw-r--r--Jellyfin.Api/Helpers/TranscodingJobHelper.cs5
-rw-r--r--Jellyfin.Drawing.Skia/SkiaEncoder.cs7
-rw-r--r--Jellyfin.Server.Implementations/Users/DefaultPasswordResetProvider.cs2
-rw-r--r--MediaBrowser.LocalMetadata/Savers/BaseXmlSaver.cs3
18 files changed, 40 insertions, 27 deletions
diff --git a/Emby.Server.Implementations/AppBase/ConfigurationHelper.cs b/Emby.Server.Implementations/AppBase/ConfigurationHelper.cs
index e19ce5edf..8cca5cc77 100644
--- a/Emby.Server.Implementations/AppBase/ConfigurationHelper.cs
+++ b/Emby.Server.Implementations/AppBase/ConfigurationHelper.cs
@@ -3,6 +3,7 @@
using System;
using System.IO;
using System.Linq;
+using MediaBrowser.Common.Extensions;
using MediaBrowser.Model.Serialization;
namespace Emby.Server.Implementations.AppBase
@@ -36,7 +37,7 @@ namespace Emby.Server.Implementations.AppBase
catch (Exception)
{
var instanceConfiguration = Activator.CreateInstance(type);
- configuration = instanceConfiguration ?? throw new NullReferenceException(nameof(instanceConfiguration));
+ configuration = instanceConfiguration ?? throw new ResourceNotFoundException(nameof(instanceConfiguration));
}
using var stream = new MemoryStream(buffer?.Length ?? 0);
@@ -52,7 +53,7 @@ namespace Emby.Server.Implementations.AppBase
var directory = Path.GetDirectoryName(path);
if (directory == null)
{
- throw new NullReferenceException(nameof(directory));
+ throw new ResourceNotFoundException(nameof(directory));
}
Directory.CreateDirectory(directory);
diff --git a/Emby.Server.Implementations/Cryptography/CryptographyProvider.cs b/Emby.Server.Implementations/Cryptography/CryptographyProvider.cs
index a48b6f356..8d7f73b3c 100644
--- a/Emby.Server.Implementations/Cryptography/CryptographyProvider.cs
+++ b/Emby.Server.Implementations/Cryptography/CryptographyProvider.cs
@@ -3,6 +3,7 @@
using System;
using System.Collections.Generic;
using System.Security.Cryptography;
+using MediaBrowser.Common.Extensions;
using MediaBrowser.Model.Cryptography;
using static MediaBrowser.Common.Cryptography.Constants;
@@ -83,7 +84,7 @@ namespace Emby.Server.Implementations.Cryptography
using var h = HashAlgorithm.Create(hashMethod);
if (h == null)
{
- throw new NullReferenceException(nameof(h));
+ throw new ResourceNotFoundException(nameof(h));
}
if (salt.Length == 0)
diff --git a/Emby.Server.Implementations/Session/WebSocketController.cs b/Emby.Server.Implementations/Session/WebSocketController.cs
index 7559ccb78..78f83e337 100644
--- a/Emby.Server.Implementations/Session/WebSocketController.cs
+++ b/Emby.Server.Implementations/Session/WebSocketController.cs
@@ -8,6 +8,7 @@ using System.Linq;
using System.Net.WebSockets;
using System.Threading;
using System.Threading.Tasks;
+using MediaBrowser.Common.Extensions;
using MediaBrowser.Controller.Net;
using MediaBrowser.Controller.Session;
using MediaBrowser.Model.Net;
@@ -59,7 +60,7 @@ namespace Emby.Server.Implementations.Session
{
if (sender == null)
{
- throw new NullReferenceException(nameof(sender));
+ throw new ResourceNotFoundException(nameof(sender));
}
var connection = (IWebSocketConnection)sender;
diff --git a/Jellyfin.Api/Controllers/DynamicHlsController.cs b/Jellyfin.Api/Controllers/DynamicHlsController.cs
index b0d5a7cd8..64bea999f 100644
--- a/Jellyfin.Api/Controllers/DynamicHlsController.cs
+++ b/Jellyfin.Api/Controllers/DynamicHlsController.cs
@@ -14,6 +14,7 @@ using Jellyfin.Api.Helpers;
using Jellyfin.Api.Models.PlaybackDtos;
using Jellyfin.Api.Models.StreamingDtos;
using MediaBrowser.Common.Configuration;
+using MediaBrowser.Common.Extensions;
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Devices;
using MediaBrowser.Controller.Dlna;
@@ -1350,7 +1351,7 @@ namespace Jellyfin.Api.Controllers
var directory = Path.GetDirectoryName(outputPath);
if (directory == null)
{
- throw new NullReferenceException(nameof(directory));
+ throw new ResourceNotFoundException(nameof(directory));
}
var outputTsArg = Path.Combine(directory, Path.GetFileNameWithoutExtension(outputPath)) + "%d" + GetSegmentFileExtension(state.Request.SegmentContainer);
@@ -1574,7 +1575,7 @@ namespace Jellyfin.Api.Controllers
var folder = Path.GetDirectoryName(playlist);
if (folder == null)
{
- throw new NullReferenceException(nameof(folder));
+ throw new ResourceNotFoundException(nameof(folder));
}
var filename = Path.GetFileNameWithoutExtension(playlist);
diff --git a/Jellyfin.Api/Controllers/EnvironmentController.cs b/Jellyfin.Api/Controllers/EnvironmentController.cs
index 8de217bbf..6dd536254 100644
--- a/Jellyfin.Api/Controllers/EnvironmentController.cs
+++ b/Jellyfin.Api/Controllers/EnvironmentController.cs
@@ -5,6 +5,7 @@ using System.IO;
using System.Linq;
using Jellyfin.Api.Constants;
using Jellyfin.Api.Models.EnvironmentDtos;
+using MediaBrowser.Common.Extensions;
using MediaBrowser.Model.IO;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
@@ -105,7 +106,7 @@ namespace Jellyfin.Api.Controllers
{
if (validatePathDto.Path == null)
{
- throw new NullReferenceException(nameof(validatePathDto.Path));
+ throw new ResourceNotFoundException(nameof(validatePathDto.Path));
}
var file = Path.Combine(validatePathDto.Path, Guid.NewGuid().ToString());
diff --git a/Jellyfin.Api/Controllers/HlsSegmentController.cs b/Jellyfin.Api/Controllers/HlsSegmentController.cs
index 2cee0e9ef..fe1ffacb0 100644
--- a/Jellyfin.Api/Controllers/HlsSegmentController.cs
+++ b/Jellyfin.Api/Controllers/HlsSegmentController.cs
@@ -8,6 +8,7 @@ using Jellyfin.Api.Attributes;
using Jellyfin.Api.Constants;
using Jellyfin.Api.Helpers;
using MediaBrowser.Common.Configuration;
+using MediaBrowser.Common.Extensions;
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.MediaEncoding;
using MediaBrowser.Model.IO;
@@ -138,7 +139,7 @@ namespace Jellyfin.Api.Controllers
if (playlistPath == null)
{
- throw new NullReferenceException(nameof(playlistPath));
+ throw new ResourceNotFoundException(nameof(playlistPath));
}
return GetFileResult(file, playlistPath);
diff --git a/Jellyfin.Api/Controllers/ItemLookupController.cs b/Jellyfin.Api/Controllers/ItemLookupController.cs
index b6cb79716..b14840f80 100644
--- a/Jellyfin.Api/Controllers/ItemLookupController.cs
+++ b/Jellyfin.Api/Controllers/ItemLookupController.cs
@@ -336,7 +336,7 @@ namespace Jellyfin.Api.Controllers
using var result = await _providerManager.GetSearchImage(providerName, url, CancellationToken.None).ConfigureAwait(false);
if (result.Content.Headers.ContentType?.MediaType == null)
{
- throw new NullReferenceException(nameof(result.Content.Headers.ContentType));
+ throw new ResourceNotFoundException(nameof(result.Content.Headers.ContentType));
}
var ext = result.Content.Headers.ContentType.MediaType.Split('/')[^1];
@@ -345,7 +345,7 @@ namespace Jellyfin.Api.Controllers
var directory = Path.GetDirectoryName(fullCachePath);
if (directory == null)
{
- throw new NullReferenceException(nameof(directory));
+ throw new ResourceNotFoundException(nameof(directory));
}
Directory.CreateDirectory(directory);
@@ -365,7 +365,7 @@ namespace Jellyfin.Api.Controllers
var pointerCacheDirectory = Path.GetDirectoryName(pointerCachePath);
if (pointerCacheDirectory == null)
{
- throw new NullReferenceException(nameof(pointerCacheDirectory));
+ throw new ResourceNotFoundException(nameof(pointerCacheDirectory));
}
Directory.CreateDirectory(pointerCacheDirectory);
diff --git a/Jellyfin.Api/Controllers/RemoteImageController.cs b/Jellyfin.Api/Controllers/RemoteImageController.cs
index ad76b3984..2566f574c 100644
--- a/Jellyfin.Api/Controllers/RemoteImageController.cs
+++ b/Jellyfin.Api/Controllers/RemoteImageController.cs
@@ -251,7 +251,7 @@ namespace Jellyfin.Api.Controllers
using var response = await httpClient.GetAsync(url).ConfigureAwait(false);
if (response.Content.Headers.ContentType?.MediaType == null)
{
- throw new NullReferenceException(nameof(response.Content.Headers.ContentType));
+ throw new ResourceNotFoundException(nameof(response.Content.Headers.ContentType));
}
var ext = response.Content.Headers.ContentType.MediaType.Split('/').Last();
@@ -260,7 +260,7 @@ namespace Jellyfin.Api.Controllers
var fullCacheDirectory = Path.GetDirectoryName(fullCachePath);
if (fullCacheDirectory == null)
{
- throw new NullReferenceException(nameof(fullCacheDirectory));
+ throw new ResourceNotFoundException(nameof(fullCacheDirectory));
}
Directory.CreateDirectory(fullCacheDirectory);
@@ -270,7 +270,7 @@ namespace Jellyfin.Api.Controllers
var pointerCacheDirectory = Path.GetDirectoryName(pointerCachePath);
if (pointerCacheDirectory == null)
{
- throw new NullReferenceException(nameof(pointerCacheDirectory));
+ throw new ResourceNotFoundException(nameof(pointerCacheDirectory));
}
Directory.CreateDirectory(pointerCacheDirectory);
diff --git a/Jellyfin.Api/Controllers/VideoHlsController.cs b/Jellyfin.Api/Controllers/VideoHlsController.cs
index 517239966..c47876beb 100644
--- a/Jellyfin.Api/Controllers/VideoHlsController.cs
+++ b/Jellyfin.Api/Controllers/VideoHlsController.cs
@@ -11,6 +11,7 @@ using Jellyfin.Api.Helpers;
using Jellyfin.Api.Models.PlaybackDtos;
using Jellyfin.Api.Models.StreamingDtos;
using MediaBrowser.Common.Configuration;
+using MediaBrowser.Common.Extensions;
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Devices;
using MediaBrowser.Controller.Dlna;
@@ -364,7 +365,7 @@ namespace Jellyfin.Api.Controllers
var directory = Path.GetDirectoryName(outputPath);
if (directory == null)
{
- throw new NullReferenceException(nameof(directory));
+ throw new ResourceNotFoundException(nameof(directory));
}
var outputTsArg = Path.Combine(directory, Path.GetFileNameWithoutExtension(outputPath)) + "%d" + format;
diff --git a/Jellyfin.Api/Helpers/AudioHelper.cs b/Jellyfin.Api/Helpers/AudioHelper.cs
index c6d577b19..21ec2d32f 100644
--- a/Jellyfin.Api/Helpers/AudioHelper.cs
+++ b/Jellyfin.Api/Helpers/AudioHelper.cs
@@ -4,6 +4,7 @@ using System.Threading;
using System.Threading.Tasks;
using Jellyfin.Api.Models.StreamingDtos;
using MediaBrowser.Common.Configuration;
+using MediaBrowser.Common.Extensions;
using MediaBrowser.Common.Net;
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Devices;
@@ -101,7 +102,7 @@ namespace Jellyfin.Api.Helpers
{
if (_httpContextAccessor.HttpContext == null)
{
- throw new NullReferenceException(nameof(_httpContextAccessor.HttpContext));
+ throw new ResourceNotFoundException(nameof(_httpContextAccessor.HttpContext));
}
bool isHeadRequest = _httpContextAccessor.HttpContext.Request.Method == System.Net.WebRequestMethods.Http.Head;
diff --git a/Jellyfin.Api/Helpers/DynamicHlsHelper.cs b/Jellyfin.Api/Helpers/DynamicHlsHelper.cs
index 20bca731f..e7fac50c6 100644
--- a/Jellyfin.Api/Helpers/DynamicHlsHelper.cs
+++ b/Jellyfin.Api/Helpers/DynamicHlsHelper.cs
@@ -132,7 +132,7 @@ namespace Jellyfin.Api.Helpers
{
if (_httpContextAccessor.HttpContext == null)
{
- throw new NullReferenceException(nameof(_httpContextAccessor.HttpContext));
+ throw new ResourceNotFoundException(nameof(_httpContextAccessor.HttpContext));
}
using var state = await StreamingHelpers.GetStreamingState(
diff --git a/Jellyfin.Api/Helpers/HlsHelpers.cs b/Jellyfin.Api/Helpers/HlsHelpers.cs
index 16fbac7ae..707d1cd10 100644
--- a/Jellyfin.Api/Helpers/HlsHelpers.cs
+++ b/Jellyfin.Api/Helpers/HlsHelpers.cs
@@ -3,6 +3,7 @@ using System.Globalization;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
+using MediaBrowser.Common.Extensions;
using MediaBrowser.Model.IO;
using Microsoft.Extensions.Logging;
@@ -47,7 +48,7 @@ namespace Jellyfin.Api.Helpers
var line = await reader.ReadLineAsync().ConfigureAwait(false);
if (line == null)
{
- throw new NullReferenceException(nameof(line));
+ throw new ResourceNotFoundException(nameof(line));
}
if (line.IndexOf("#EXTINF:", StringComparison.OrdinalIgnoreCase) != -1)
diff --git a/Jellyfin.Api/Helpers/ProgressiveFileCopier.cs b/Jellyfin.Api/Helpers/ProgressiveFileCopier.cs
index 65c03c710..8bddf00d5 100644
--- a/Jellyfin.Api/Helpers/ProgressiveFileCopier.cs
+++ b/Jellyfin.Api/Helpers/ProgressiveFileCopier.cs
@@ -5,6 +5,7 @@ using System.Runtime.InteropServices;
using System.Threading;
using System.Threading.Tasks;
using Jellyfin.Api.Models.PlaybackDtos;
+using MediaBrowser.Common.Extensions;
using MediaBrowser.Controller.Library;
using MediaBrowser.Model.IO;
@@ -92,7 +93,7 @@ namespace Jellyfin.Api.Helpers
if (_path == null)
{
- throw new NullReferenceException(nameof(_path));
+ throw new ResourceNotFoundException(nameof(_path));
}
await using var inputStream = new FileStream(_path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite, IODefaults.FileStreamBufferSize, fileOptions);
diff --git a/Jellyfin.Api/Helpers/StreamingHelpers.cs b/Jellyfin.Api/Helpers/StreamingHelpers.cs
index 1d102071c..04b107727 100644
--- a/Jellyfin.Api/Helpers/StreamingHelpers.cs
+++ b/Jellyfin.Api/Helpers/StreamingHelpers.cs
@@ -85,7 +85,7 @@ namespace Jellyfin.Api.Helpers
streamingRequest.StreamOptions = ParseStreamOptions(httpRequest.Query);
if (httpRequest.Path.Value == null)
{
- throw new NullReferenceException(nameof(httpRequest.Path));
+ throw new ResourceNotFoundException(nameof(httpRequest.Path));
}
var url = httpRequest.Path.Value.Split('.').Last();
diff --git a/Jellyfin.Api/Helpers/TranscodingJobHelper.cs b/Jellyfin.Api/Helpers/TranscodingJobHelper.cs
index b72e33af3..4ec0c576a 100644
--- a/Jellyfin.Api/Helpers/TranscodingJobHelper.cs
+++ b/Jellyfin.Api/Helpers/TranscodingJobHelper.cs
@@ -12,6 +12,7 @@ using Jellyfin.Api.Models.PlaybackDtos;
using Jellyfin.Api.Models.StreamingDtos;
using Jellyfin.Data.Enums;
using MediaBrowser.Common.Configuration;
+using MediaBrowser.Common.Extensions;
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.MediaEncoding;
@@ -198,7 +199,7 @@ namespace Jellyfin.Api.Helpers
var job = (TranscodingJobDto?)state;
if (job == null)
{
- throw new NullReferenceException(nameof(job));
+ throw new ResourceNotFoundException(nameof(job));
}
if (!job.HasExited && job.Type != TranscodingJobType.Progressive)
@@ -496,7 +497,7 @@ namespace Jellyfin.Api.Helpers
var directory = Path.GetDirectoryName(outputPath);
if (directory == null)
{
- throw new NullReferenceException(nameof(directory));
+ throw new ResourceNotFoundException(nameof(directory));
}
Directory.CreateDirectory(directory);
diff --git a/Jellyfin.Drawing.Skia/SkiaEncoder.cs b/Jellyfin.Drawing.Skia/SkiaEncoder.cs
index ad066c524..1570d247b 100644
--- a/Jellyfin.Drawing.Skia/SkiaEncoder.cs
+++ b/Jellyfin.Drawing.Skia/SkiaEncoder.cs
@@ -4,6 +4,7 @@ using System.Globalization;
using System.IO;
using BlurHashSharp.SkiaSharp;
using MediaBrowser.Common.Configuration;
+using MediaBrowser.Common.Extensions;
using MediaBrowser.Controller.Drawing;
using MediaBrowser.Controller.Extensions;
using MediaBrowser.Model.Drawing;
@@ -230,7 +231,7 @@ namespace Jellyfin.Drawing.Skia
var directory = Path.GetDirectoryName(tempPath);
if (directory == null)
{
- throw new NullReferenceException(nameof(directory));
+ throw new ResourceNotFoundException(nameof(directory));
}
Directory.CreateDirectory(directory);
@@ -501,7 +502,7 @@ namespace Jellyfin.Drawing.Skia
var outputDirectory = Path.GetDirectoryName(outputPath);
if (outputDirectory == null)
{
- throw new NullReferenceException(nameof(outputDirectory));
+ throw new ResourceNotFoundException(nameof(outputDirectory));
}
Directory.CreateDirectory(outputDirectory);
@@ -554,7 +555,7 @@ namespace Jellyfin.Drawing.Skia
var directory = Path.GetDirectoryName(outputPath);
if (directory == null)
{
- throw new NullReferenceException(nameof(directory));
+ throw new ResourceNotFoundException(nameof(directory));
}
Directory.CreateDirectory(directory);
diff --git a/Jellyfin.Server.Implementations/Users/DefaultPasswordResetProvider.cs b/Jellyfin.Server.Implementations/Users/DefaultPasswordResetProvider.cs
index ced25524e..465fb09cd 100644
--- a/Jellyfin.Server.Implementations/Users/DefaultPasswordResetProvider.cs
+++ b/Jellyfin.Server.Implementations/Users/DefaultPasswordResetProvider.cs
@@ -62,7 +62,7 @@ namespace Jellyfin.Server.Implementations.Users
if (spr == null)
{
- throw new NullReferenceException(nameof(spr));
+ throw new ResourceNotFoundException(nameof(spr));
}
if (spr.ExpirationDate < DateTime.UtcNow)
diff --git a/MediaBrowser.LocalMetadata/Savers/BaseXmlSaver.cs b/MediaBrowser.LocalMetadata/Savers/BaseXmlSaver.cs
index 11ad69d91..da04203e0 100644
--- a/MediaBrowser.LocalMetadata/Savers/BaseXmlSaver.cs
+++ b/MediaBrowser.LocalMetadata/Savers/BaseXmlSaver.cs
@@ -5,6 +5,7 @@ using System.Linq;
using System.Text;
using System.Threading;
using System.Xml;
+using MediaBrowser.Common.Extensions;
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.Movies;
@@ -130,7 +131,7 @@ namespace MediaBrowser.LocalMetadata.Savers
var directory = Path.GetDirectoryName(path);
if (directory == null)
{
- throw new NullReferenceException(nameof(directory));
+ throw new ResourceNotFoundException(nameof(directory));
}
Directory.CreateDirectory(directory);